How can a web server handle multiple user's incoming requests at a time on a single port (80)?

前端 未结 5 507
长情又很酷
长情又很酷 2020-12-12 17:23

How does a web server handle multiple incoming requests at the same time on a single port(80)?

Example : At the same time 300k users want to see an image from www.ab

5条回答
  •  春和景丽
    2020-12-12 17:58

    1) How does a web server handle multiple incoming requests at the same time on a single port(80)
    ==> a) one instance of the web service( example: spring boot micro service) runs/listens in the server machine at port 80.
    b) This webservice(Spring boot app) needs a servlet container like mostly tomcat.
    This container will have thread pool configured.
    c) when ever request come from different users simultaneously, this container will
    assign each thread from the pool for each of the incoming requests.
    d) Since the server side web service code will have beans(in case java) mostly
    singleton, each thread pert aining to each request will call the singleton API's
    and if there is a need for Database access , then synchronization of these
    threads is needed which is done through the @transactional annotation. This
    annotation synchronizes the database operation.

    2) Can one server (which is assigned with IP 10.10.100.100) handle this vast amount of incoming users?
    If not, then how can one IP address be assigned to more than one server to handle this load?
    ==> This will taken care by loadbalancer along with routetable

提交回复
热议问题