I am working on a project
1.which requires several processes to be listening for requests on unique ports(possibly on multiple hosts)
2.Every process is meant to serve a unique client
3.The clients should connect to there respective server process using client_id.domainname.com as the identifier / end point.
Ex: requests coming to
client_id_1.domainname.com:FIXED_PORT should go to host_1:port_1
client_id_2.domainname.com:FIXED_PORT should go to host_2:port_2
etc..
[Edited for clarification : the port number with which client will access should be fixed.Only the client_id would change with change in client]
4.[Edited(had missed this point)]. The mapping needs to be dynamic/modifiable .Example if one the processes die ,another has to be brought up which might not be on the same port
I have tried the following approaches(using java)
1.implemented tcp server,and tried using tcp portforwarding using http://code.google.com/p/portforward/ and other similar stuff that i found by searching.The problem is this uses InetAddress which does not have the request uri(to get the client id using subdomain from uri)
2.implemented server processes as Servlets in embedded jetty.This is fine only for GET requests. GET requests can be redirected to specific server using
httpServletResonse.sendRedirect("http://host_1:port_1")
for POST we have RequestDispatcher which ultimately resuls in a GET.It seems that the HTTP specification doesnt allow a redirect with POST.
I also found this Calling the doPost in another Webapp with a Req Dispatcher forward which suggests to to fire a POST request yourself programmatically.(I havent still worked on this approach yet)
I hope there is a solution for this. I might be highly oversimplifying, but I think this is similar to what HEROKU does.They also have backend processes(dynos) which run on different ports(i am not sure about this).They are matched with incoming requests based on the app-name.The following discusses http://www.quora.com/Scalability/How-does-Heroku-work but this question is not answered.
I have been stuck for quite sometime on this.I would be realy thankful for your help.