Answer the question
In order to leave comments, you need to log in
How to optimize a server for 5 million hits?
Good afternoon!
There is a certain project written in Python using Django. The service does not have any special logic, the essence is quite simple: when you go to the appropriate URL, we write some data to the session and statistics in the database, and redirect to another URL.
PostgreSQL is used as a database, sessions are stored in Redis.
The server is quite powerful 4 cores (8 threads), 8 RAM.
During tests, Nginx logs began to appear messages like:
(11: Resource temporarily unavailable)
Answer the question
In order to leave comments, you need to log in
The problem is that sooner or later you will still run into the inability to increase the number of workers. Separate the collection of statistics directly and storing it in a relatively slow database. That is, going to the URL does only fast work (increase the counter in the conditional radish / memcache, write something to the session) and frees the worker to service the next request, and saving to the database is done by individual workers with some frequency.
You can look in the direction of the Nginx + Lua bundle, their capabilities may be enough for the "fast" part.
Perhaps the main problem lies in parallel threads. When the limit is reached, the server issues such a message. Check and increase this value in the configuration files.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question