title: Socket Programming - Does Server Queue Requests?
body: <p>I am working on socket programming on Java recently and something is confusing me. I have three questions about it.</p>
  
  <p><strong>First one is;</strong></p>
  
  <p>There is a <code>ServerSocket</code> method in Java. And this method can take up to 3 parameters such as <code>port</code>, <code>backlog</code> and <code>ip address</code>. Backlog means # of clients that can connect as a form of queue into a server. Now lets think about this situation.</p>
  
  <blockquote>
    <p>What happens if 10 clients try to connect this server at the same
    time?</p>
  </blockquote>
  
  <p>Does Server drop last 5 clients which tried to connect? Lets increase the number of clients up to 1 million per hour. How can I handle all of them? </p>
  
  <hr>
  
  <p><strong>Second question is;</strong></p>
  
  <p>Can a client send messages concurrently without waiting server's response? What happens if a client sends 5 messages into server that has 5 backlog size?</p>
  
  <hr>
  
  <p><strong>The last one is not a question actually</strong>. I have a plan to manage load balancing in my mind. Lets assume we have 3 servers running on a machine.</p>
  
  <p>Let the servers names are A, B and C and both of them are running smoothly. According to my plan, if I gave them a priority according to incoming messages then smallest priority means the most available server. For example;</p>
  
  <p>Initial priorities -> A(0), B(0), C(0) and respond time is at the end of 5. time unit.</p>
  
  <p>1.Message -> A (1), B(0), C(0)</p>
  
  <p>2.Message -> A (1), B(1), C(0)</p>
  
  <p>3.Message -> A (1), B(1), C(1)</p>
  
  <p>4.Message -> A (2), B(1), C(1)</p>
  
  <p>5.Message -> A (2), B(2), C(1)</p>
  
  <p>6.Message -> A (1), B(2), C(2)</p>
  
  <p>.
  .
  .</p>
  
  <p>Is this logic good? I bet there is a far better logic. What do I do to handle more or less a few million requests in a day? </p>
  
  <p>PS: All this logic is going to be implemented into Java Spring-Boot project.</p>
  
  <p>Thanks</p>