What determines number of simultaneous connections

前端 未结 6 1600
予麋鹿
予麋鹿 2021-01-31 19:06

In a Java servlet environment, what are the factors that are the bottleneck for number of simultaneous users.

  1. Number of HTTP connections the server can allow per
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 19:17

    There is another common bottleneck : the size of the database connection pool. But I have an additional remark : when you exhaust the number of allowed HTTP connections, of the number of threads allowed to serve request, you will only reject some requests. But when you exhaust memory (too much sessions with too much data for example), you can crash the whole application.

    The difference is that in the case of heavy load for a short time, when load later falls down :

    • in first case, the application is up and can serve requests normally
    • in second case the application is down and must be restarted

    EDIT :

    I forgot to remember real use cases. The biggest problem I ever found for serving numerous concurrent connections is the quality of the database requests (assuming you use a database). There is not a direct impact since there is no maximum number, but you can easily hog all database server resources. Common examples of poor database requests :

    • no index on a table with a large number of rows
    • a request (on a big table) that makes no use of any index
    • the n+1 syndrome : with a ORM when you map a one to many relation to a collection no eagerly when you always need data from the collection
    • the load full database syndrome : with a ORM when you map all relations as eager, any single request ends in loading a high quantity of dependent data.

    What is worse with those problems, is that they can cause no harm in tests when the database is young because there are not that many rows, but with time and increasing number of rows performances fall giving a unusable application over few users.

提交回复
热议问题