S
S
skvizart2018-04-03 19:39:02
PHP
skvizart, 2018-04-03 19:39:02

How is adding news or posts to the site using php + mysql?

Hello, could you please explain how news or posts are added to large sites or portals? All records are added to the database and every time the user visits the php script accesses the database? Or is the data from the database written to the html file and downloading news or something already lies on the shoulders of the browser? I ask you not to judge me strictly, since I just started to study this topic and I don’t really understand yet how it is implemented, I would be happy to look at ready-made scripts and implementation if I could fully understand and understand what is described in them.
I have a question, if, for example, the site has 10/20/30 news on one page and many people visit this page at the same time (for example, 10,000), will the load on the site be too large? After all it is necessary for everyone to address to a DB and to give this data?
Maybe you have somewhere bookmarked some kind of article in which it is described in detail how everything happens? Or maybe you have a little free time and you can explain to me how these very news are displayed to the user, I will be sincerely grateful to you. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lazy @BojackHorseman PHP, 2018-04-03
@skvizart

if on the fingers, then this is the case.
the first user actually accesses the database, gets the result (and this will be a very fast query - 30 records on top of the indexed table) and puts it in the cache. the next one will not recalculate this data, but will take it from the cache. and so on until new news is added (this happens more than once per second, obviously), the cache becomes obsolete, the next user recalculates the data and puts it in the cache again.
not everything, of course, is so perfect, but the situation is such that this particular request will take a small %% of the total time to generate a response to a request to the server
ps on really large rps values, there are effects of a different order, such as sharp bursts of load due to competing requests at the moment immediately after the cache becomes obsolete, to solve which they use its artificial "warming up"

S
Stalker_RED, 2018-04-04
@Stalker_RED

All records are added to the database and every time the user visits the php script accesses the database?
In general terms, they have already explained to you, but it’s better for you not to bother with this yet, but to do it “head on” - get data from the database for each request. You don't really have 10k visitors, and this is pure theorycraft?
If it is still interesting to read about highly loaded systems, then you can look for books on highload or see the relevant sections on Habré, for example.

A
Alex-1917, 2018-04-12
@alex-1917

Listen, beginner!! I advise you to start studying not with deepening into technical details, especially since you fatally swim in them, but with more important things:
1. the ability to search by parallelizing queries (not Toaster, but Toaster + Google + SC + ... + queries in English. language)
2. setting before yourself and, accordingly, before the respected community of the TOASTER TASKS, and not ephemeral pink-eyed flights of thought
Having mastered these two methods, the speed of completing the task will already increase by at least 34-56%!
Well, what
??!! Are you seriously talking about SIMULTANEOUS visits to 10,000 people ???)))
Projects with such a level of visits for 200 years in advance are reserved for studios with half a billion budgets, and you don’t belong there and they don’t sit here for me))) You don’t have them writing is not programming, so do not create a problem for yourself and do not rush to solve it, just reformulate your task for 50-200 visits per DAY !!!
In order not to be unfounded - YouTube is 120 million per day, divided by 86400 seconds = 1388! 1388 visits per second. and this visit is not ONE page, as it were ... if you divide it into a billion YouTube pages, then what will you get in the balance ...???)))
Well, start (or end) today by reading the most useful article Premature optimization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question