I know it is very basic. But want to clear some concept of mysql connections. I have following scenario.
- Db server and web servers are on different locations.
- Web server is running an article based web site.
- Articles data is stored in db server.
- Web server is delivering 100 articles/pages per second.
My questions are as follows:
- Single connection between web server and db server can handle it ?
- How many connections would be created by default ?
- If I suppose connections as pipes, what is i/o capacity of each connection ?
- Is there any relationship between db server’s RAM, processor, OS and number of connections ?
Thanks in advance
A single connection can pass several requests, but not at the same time, and only for a single client process. So the best scaling approach might be one connection pool per web server process, where threads can obtain an established connection to perform their request, and return the connection to the pool once they are done.
Depends on the client language, the MySQL connector implementation, the frameworks you use, the web server configuration, and probably a bunch of other details like this. So your best bet is to simply look at the list of network connections to the MySQL service, e.g. using
lsofornetstat.The limiting factor will probably be shared resources, like the network bandwidth or processing capabilities at either end. So the number of connections shouldn’t have a large impact on the data transfer rate. The overhead to establish a connection is significant, though, which is why I suggested reducing the number of connections using pooling.
Might be, if some application makes choices based on these parameters, but in general I’d consider this rather unlikely.