B
B
BonBon Slick2020-07-10 09:37:33
Highload
BonBon Slick, 2020-07-10 09:37:33

How to deal with 200,000 concurrent connections?

Debian OS, server nginx, lang php.
How to synchronize DB and locks, for example, to update and read an entity, etc.?
What are the associated problems and their solutions?

What are your ideas or how do sites like google, FB, YouTube and others manage such a load?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKEPTIC, 2020-07-10
@BonBonSlick

See what site you have there.
But in general it all comes down to scaling.
1) Frontend scaling (with all sorts of round-robin dns and other technologies)
2) Backend scaling (in the nginx configs on the front, you write all the backs and somehow distribute the load. It can be a banal ROUND-ROBIN or something smarter)
3) Database scaling. Probably the most difficult. Here, 2 approaches are most often used. These are sharding and replication.
Sharding can be used when there is a lot of data and it is often requested and written. You distribute data across servers according to a certain attribute. For example, a table with user accounts. Suddenly, you have tokens for authentication in the same table. Then you simply separate the data on several servers by attribute. For example, you turn the user's login into a number using a certain algorithm and take the remainder of the division by the number of shards + 1. (user_id % shards_count + 1).
Replication is used for data persistence and for scaling. For example, you have a table with news for today, but they are very popular. You take and create master-slave replication. Slaves copy data from the master and participate in the return of data to users.
You can use both scaling and sharding for the same data at the same time if their loss is critical or if the load is too large for one shard.
Something like that. One server is unlikely to digest 200k simultaneous connections if you have a more or less heavy site, and not a one-page with Hello World.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question