Relay server

I’m looking for ideas how to implement some sort of TCP relay server.

How it should work is something like (each request):

  • Client sends a request to the Relay-Server.
  • Relay-Server processes that request.
  • The processed request is sent forward as a request to the Target-Server.
  • Target-Server replies to the request, and the Relay-Server receives this reply.
  • Relay-Server processes the reply.
  • The processed reply is sent forward to the original Client.

Basically the Relay-Server works as a receiver for requests from Client and forwards it to a Target-Server, which will reply.

This is some sort of a proxy, but where I need to modify the requests from Client and responses of Target-Server. So, some sort of proxy-interpreter.

Any ideas how to mingle these two together, Server and Client?

Oh yea, it should be able to handle thousands of clients :slight_smile:

I assume HTTP ??

I have written such a (HTTP) thing, and it keeps a bunch of websites online, so it’s stable.

It feeds on (small) XML files. You can specify multiple targets (slaves), the proxy remembers each client’s an ‘affinity address’ (either using cookies or datastructure in RAM, using a LRU algorithm). The code is setup in such a way that you can modify both the request and response headers.

Per second? Concurrent? The usual approach of a proxy is to close the TCP connection after every http request/response, to keep the amount of concurrent connections down to a minimum. You won’t notice it in client-side performance, it might add a few milliseconds.

It is written in (old) I/O. (read up on why: http://mailinator.blogspot.com/2008/02/kill-myth-please-nio-is-not-faster-than.html)

If you want to see the code… I can PM you if you wish.

Sure, PM me :slight_smile: Might give me some ideas. There are many paths to choose from, I just need to find the best one.

FYI: HAProxy is also widely used.