I have found an app that the web server redirects some requests backend to the server, and backend server (Linux),
Complicated Works For Computing and Web Server Response To TCP Socket Connection Management Between Web Server and Backend Server, I think there are two basic strategies:
-
"Compact" connection : That is, a connection per request. This socket looks very easy for management and simplifies the entire program structure. After accept , we receive some thread to process on request and finally
close . "long" connection: that is, for a TCP connection, one request may be multiplied by one, it seems that this strategy can make better use of socket processing. And some can improve performance (I'm not sure). But It seems that this brings a lot of complexity from the "short" connection. For example, since the socket FD can now be used by multi-threads, it should be included in the synchronization. More, socket failure process, message sequence ...
Is there any suggestion for these two strategies?
Update: , @SargeATM's answer reminds me that I should tell more about backend service. Each request is referenced in a way that the backend service can count on a single request message. It seems sth stateless.
without adding to the backend architecture which I think has a huge effect on this decision, I I like less.
I know that there is some TCP overhead to establish a new connection (if it's not local), "Quick" request / response type of traffic and synchronization or file locally Long-term states for transfer protocols like transfer Kshn. Host) but it was never anything to optimize in my applications.
OK, I'll get something in architecture because it's important. I always use the thread, not the thread, but with the request. So I would have a thread that listened to the socket. Another thread that closes the packet from all active connections and is calculating backend on the second thread and if necessary, save the last thread to the database. It keeps things clean and easy to measure slow spots, easy to measure, and to adapt later, if needed.
Comments
Post a Comment