title: Overhead of WebSockets on Apache Server
body: <p>I have built a website with <code>PHP + Apache + JS + HTML 5</code>. Now there is a point where I have to tell the user every second if the server is connected and ready to receive data and/or internet connection is lost/available or whatever else which can tell the user to not to send data to server because of unavailability of Server or internet connection. </p>
  
  <p>For this purpose I can either move to <code>Long Polling with Ajax</code> and keep pinging my server every second but surely this will cause alot of network overhead on my Apache Server where my clients are about tens of thousands live at a time so keep pinging the server is not a good option. Therefore, I decided to use WebSockets.</p>
  
  <p>I have been googling for about 2 days but yet could not find enough good article to answer my 3 basic questions regarding <code>WebSocket</code> and <code>Apache + PHP</code>.</p>
  
  <p>1) If once the WebSocket connection is made with server, then does it remain active like Long Polling with Server or what is the mechanism behind it? I mean how does WebSocket maintain its relation with server does it keep polling with server and hence there is always a connection between Client and Server?</p>
  
  <p>2) If your answer to above question is yes then what network/IO overhead would be on server side if I use websockets because there is a continuous connection between Client and Server. And imagine if there are hundreds of thousands of clients online at a time what load will it create on Server Network or IO?</p>
  
  <p>3) What is the Best approach to use WebSockets when using Apache + PHP on server? Any good article on this where I can study how to communicate with Apache Server using WebSockets? I found this question, but it doesn't answer well <a href="https://stackoverflow.com/questions/11334320/using-websocket-on-apache-server">Using WebSocket on Apache server</a>. In this question, it limits the experts to not to include any answer which has sysadmin tools, while I am asking for it if any required.</p>
  
  <p>I have a VPS Server so tunning and installing some tools isn't a problem.</p>
  
  <p>Any help would be highly appreciated. Thanks with Regards.</p>