I have a web page made with laravel and mysql, and it has enough access to the database, and I would like to know how to measure how many simultaneous users making queries my page can hold.
I have a basic server in digital ocean with the following characteristics:
512MB (1 CPU) 20GB (SSD DISK) 1000GB (Transfer)
and it has many different servers and the highest one has the characteristics:
224GB (1 CPU) 500GB (SSD DISK) 10TB (Transfer)
Really a lot of difference, but beyond that, I don't know when to use one and when to scale to another, which would be scaling vertically. At the same time, I don't know when to scale horizontally, that is, to make replicas of the system, or to have a server that is only for the database.
I would really like to know these questions, before having future problems, even if there are few users.
Correct me if I'm wrong, when a user requests a page from your system, a connection to the database is opened, any required queries are made, the page is displayed, and the connection is closed. This operation takes say, 2 seconds. The user may be reading your page, say 10 minutes.
If your database accepts 3 simultaneous connections, you can serve 3 connections every 2 seconds or 90 connections per minute.
But even if 90 users are reading your page at the same time , they are not simultaneous connections, because the page in question is already in the client .
If at the same time 5 clients arrived to request the page, and your database server accepts 3 simultaneous connections, two of those clients would wait 2 seconds to see your page. If you increase the MySQL limit to 5, then you could serve 150 pages every minute.
Obviously, the more open connections you allow, the more resources your system consumes.
The solution is to use buffers, cache , to your database queries and pages generated by PHP. This cache, let's say it reduces the response time to 1/2 second.
Now we go to your http server. If your server accepts 50 clients simultaneously, serving 1/2 of the cached pages, it can serve 100 simultaneous pages per second .
But it's the same, open a connection, serve the page and close... no concurrent users .
Response
Apache has a program called ab that is used for stress testing or benchmarking . Shows the number of requests per second your Apache server can serve, _although I think it works for any server, because it tests under the
http
.It is used like this:
With this you generate 100 requests in 20 threads, to check concurrency. On this genbeta:dev page you can see an example.