Answer the question
In order to leave comments, you need to log in
What characteristics of a virtual server are required for this workload?
Good afternoon.
There is a project that is spinning on the server next to a bunch of other customer projects. At times, all this falls, but since there is no desire to be responsible for other projects, it was decided to transfer everything to a separate virtual machine with optimal characteristics. Since I am a developer, not a sys. admin - there is only superficial knowledge about this area. Naturally, kvm + ssd and a bunch of fpm + nginx + mysql.
Collected logs for the last 10 days:
Ratio of given statics (nginx) / dynamics (fpm) - 17% / 83% The
pages are small, the statics too, the total amount of data on the disk is 3gb.
Maximum rps: 306
But it is quite rare, the general statistics are as follows:
Requests Percentage
1 - 10 33.53%
11-50 64.68%
51-100 1.42%
101-150 0.26%
151-200 0.07%
201-250 0.014%
251-300 0.003%
300+ 0.0001%
It turns out:
One third of a day - 10rps
Another two-thirds - 11-100rps
Small part: 100-300
The distribution is relatively even - requests grow from 18 to Moscow time, and by 2 am they fall to 1-50.
I took metrics from php scripts, any page is generated in 15-25ms.
ttfb - 150-300ms (depending on keep-alive) via cloudflare
One php-fpm process takes on average 20mb of memory and 10-20% cpu (top|ps)
Small database: 100mb 70%/30% (Data, indexes) (Requests are used sparingly - in-app cache)
I tried to calculate the required number of fpm workers:
avg: 50rps, 83% of which php - 40rps, for 100 ms 4rps, doubled, 8 workers should be for the eyes, from memory - 30mb (50% for a leak before restart) per 1, total: 8 workers, 240mb.
min: 10rps, logic similar to above, 2 workers, 60mb
max: 300rps, 50 workers, 1.5gb (isn't it a lot?)
ps - There is no clear understanding of these moments:
Client connected, nginx received headers, need to be sent to fpm. From what moment does it initialize the connection with the fpm worker? When he just received the headers, or when he has already received the entire request from the client, where can there be delays too?
fpm has worked - does it send everything to nginx at once and is released for the next connection, or if there is a delay with the client - nginx stops receiving data from fpm after filling its buffer, therefore the fpm worker will be busy longer?
If, based on these answers, nginx keeps the fpm worker busy to a minimum, then you can divide the number of workers by another 3, and get for the maximum load, about 18 workers, and 600mb of RAM.
Plus nginx, mysql, and get: 30gb ssd, 2 cores, 2 gigs of RAM, kvm.
Not too big/small characteristics I calculated? Necessary - the optimal amount of resources
so as not to work idle.
I would be grateful for any advice / help / calculations?
Answer the question
In order to leave comments, you need to log in
I see two options - either load testing, which will allow you to accurately determine the necessary parameters ( https://loadimpact.com/ , etc.),
or take it at random (I would start with 8gb RAM, CPU is less critical) and correct it on the go depending on monitoring results.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question