<p>I have 1 process that receives incoming connection from port 1000 in 1 <strong>linux</strong> server. However, 1 process is not fast enough to handle all the incoming request.</p>

<p>I want to run multiple processes in the server but with 1 end-point. In this way, the client will only see 1 end-point/process not multiple.</p>

<p>I have checked LVS and other Load Balancing Solution. Those solutions seem geared towards multiple servers load-balancing.</p>

<p>Any other solution to help on my case?</p>

<hr>

<p>i am looking something more like nginx where i will need to run multiple copies of my app.</p>

<p>Let me try it out.</p>

<p>Thanks for the help.</p>

[{'answer_id': 45272, 'author': 'Matt Sheppard', 'author_id': 797, 'author_profile': 'https://Stackoverflow.com/users/797', 'pm_score': 2, 'selected': False, 'text': '<p>The question is a little unclear to me, but I suspect the answer you are looking for is to have a single process accepting tasks from the network, and then forking off \'worker processes\' to actually perform the work (before returning the result to the user).</p>\n\n<p>In that way, the work which is being done does not block the acceptance of more requests.</p>\n\n<p>As you point out, the term load balancing carries the implication of multiple servers - what you want to look for is information about how to write a linux network daemon.</p>\n\n<p>The two kes system calls you\'ll want to look at are called <a href="http://en.wikipedia.org/wiki/Fork-exec" rel="nofollow noreferrer">fork and exec</a>.</p>\n'}, {'answer_id': 45356, 'author': 'Thomas Vander Stichele', 'author_id': 2900, 'author_profile': 'https://Stackoverflow.com/users/2900', 'pm_score': 2, 'selected': False, 'text': '<p>It sounds like you just need to integrate your server with <a href="http://www.xinetd.org/" rel="nofollow noreferrer">xinetd</a>.</p>\n\n<p>This is a server that listens on predefined ports (that you control through config) and forks off processes to handle the actual communication on that port.</p>\n'}, {'answer_id': 45370, 'author': 'Chris Bunch', 'author_id': 422, 'author_profile': 'https://Stackoverflow.com/users/422', 'pm_score': 3, 'selected': True, 'text': '<p>You also may want to go with a web server like <a href="http://www.nginx.net" rel="nofollow noreferrer">nginx</a>. It can load balance your app against multiple ports of the same app, and is commonly used to load balance Ruby on Rails apps (which are single threaded). The downside is that you need to run multiple copies of your app (one on each port) for this load balancing to work.</p>\n'}, {'answer_id': 46229, 'author': 'Leon Timmermans', 'author_id': 4727, 'author_profile': 'https://Stackoverflow.com/users/4727', 'pm_score': 1, 'selected': False, 'text': "<p>You need multi-processing or multi-threading. You aren't specific on the details of the server, so I can't give you advice on what to do exactly. fork and exec as Matt suggested can be a solution, but really: what kind of protocol/server are we talking about?</p>\n"}, {'answer_id': 48197, 'author': 'Niko Gunadi', 'author_id': 4499, 'author_profile': 'https://Stackoverflow.com/users/4499', 'pm_score': 0, 'selected': False, 'text': '<p>i am thinking to run multiple application similar to <a href="http://ypopsemail.com/" rel="nofollow noreferrer">ypops</a>.</p>\n'}, {'answer_id': 48219, 'author': 'Dave Verwer', 'author_id': 4496, 'author_profile': 'https://Stackoverflow.com/users/4496', 'pm_score': 0, 'selected': False, 'text': "<p>nginx is great but if you don't fancy a whole new web server, apache 2.2 with mod proxy balancer will do the same job</p>\n"}, {'answer_id': 110724, 'author': 'MarkR', 'author_id': 13724, 'author_profile': 'https://Stackoverflow.com/users/13724', 'pm_score': 0, 'selected': False, 'text': "<p>Perhaps you can modify your client to round-robin ports (say) 1000-1009 and run 10 copies of the process?</p>\n\n<p>Alternatively there must be some way of internally refactoring it.</p>\n\n<p>It's possible for several processes to listen to the same socket at once by having it opened before calling fork(), but (if it's a TCP socket) once accept() is called the resulting socket then belongs to whichever process successfully accepted the connection.</p>\n\n<p>So essentially you could use:</p>\n\n<ul>\n<li>Prefork, where you open the socket, fork a specified number of children which then share the load</li>\n<li>Post-fork, where you have one master process which accepts all the connections and forks children to handle individual sockets</li>\n<li>Threads - you can share the sockets in whatever way you like with those, as the file descriptors are not cloned, they're just available to any thread.</li>\n</ul>\n"}]
['https://Stackoverflow.com/questions/45252', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4499/']