3

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.

Community
  • 1
  • 1
gt5050
  • 561
  • 6
  • 12
  • Heroku only permit inbound connections on port 80 and port 443 - I think that rules out Heroku for you in this case? – John Beynon Dec 06 '11 at 11:10
  • would it be possible to have one host beeing the "connection-distributor" that knows the mapping for client_id to host_x:port_x? This host could simply tell the requesting clients the appropiate redirect. Or is your problem that you can't get the client_id from the request? If so: could those clients simply tell "I'm client ###" in their request? – xmoex Dec 06 '11 at 13:08
  • xmoex@ What is happening at the server should be hidden from the clients.The clients should make there request using the endpoint known to them. – gt5050 Dec 07 '11 at 04:26
  • @JohnBeynon Herkou allows connections only on 80,443 but the server processes would be running on different ports.My question is how do they forward requests based on the url. – gt5050 Dec 07 '11 at 04:29
  • Are the client browsers? Or they are raw tcp clients? – Sid Malani Dec 18 '11 at 10:15
  • @SidMalani the clients could be raw tcp clients as well – gt5050 Dec 22 '11 at 17:07

1 Answers1

0

This is not possible on the Heroku stack as it only supports the standard HTTP and HTTPS ports (80 & 443). When you spin up your process the port that the service is connected on is dictated by the Heroku infrastructure (See $PORT and Procfiles).

Trying to do anything that doesn't fit this model is not really going to work until they support more ports.

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134