2

I'm a newbie to working with servers and I have a server design question. I currently have two separate application servers that work together in the following way:

The initial connection is made with server1 which makes a few decisions(about port number and other arguments) and starts server2 with those arguments on the same machine (I would have access to the process handle of all that were created). All further requests come directly to each server2 from each client. Because of the data we are handling individual versions of server2 are needed per client. (our load isn't big so that's never an issue)

What becomes a problem is the chosen port numbers. They are not always open for our clients. So my question is how can I redesign this system so I still have individual versions of server2 but that all requests come and go through server1 instead so only its port is used externally (all ports are available internally on the machine the servers are running on)? For instance is it possible to make the two servers 'talk' to each other somehow, maybe get one to redirect to the other? would the TCP specifications become the same for multiple clients if I tried to do this? Is it possible to do this at all or do I have to rethink the entire system?

(if it matters at all, both servers are written with c++ exactly as the Poco library suggests in their documentation)

I don't need specific code just some guidelines about what possibilities exist. Any help and suggestions will be greatly appreciated.

ArezooK
  • 23
  • 6

1 Answers1

0

Not sure what protocols you are dealing with here, but it seems to me that you need one server (server1) providing both services, say "hello" and "data exchange". server1 should then be able to identify the kind of incoming connection it is receiving, and where it has to dispatch it. If you need to have individual processes for each client, you have a few possibilities. An easy one is to fork a new process per new data exchange connection (I'm talking in Unix terms here, but it's also possible for Windows, see this question). However, that may be too much overhead, and instead you may prefer to have long-lived per-client server2 instances. In that case, one option is to have server1 to act as a proxy, forward the client request to the corresponding server2 through a local/Unix socket or some other IPC mechanism (in this architecture it may make sense to use the Reactor framework in Poco); this, however, ultimately requires all the data from all clients to go through server1, which may have been the reason to split the problem in multiple processes in the first place. So the option that you have is to duplicate the client open connection socket in the server2 process (and then close the one in server1). Read this and this questions about how to do it on Unix, or this documentation for Windows (I'm not aware of Poco abstractions to do it, but then again I know little about Poco).

jdehesa
  • 58,456
  • 7
  • 77
  • 121