views:

114

answers:

2

I need to provide a C++ application as a service. Client of the service and the service can be on the same machine or distributed on different machines based on the load. This application takes a ~2KB string as input and returns almost similar size of string after some processing. Turnaround time for the client should be really quick. What is the best mechanism to implement this?

+4  A: 

Given that the input size is less than a memory page wide on localhost, it's unlikely that any mechanism is going to make a measurable difference here. As for remote machines, network latency will probably be the bottleneck rather than client/server issues.

Billy ONeal
I was thinking to use HTTP as RPC in case of different machines. On single machine I can have HTTP or shared memory. What will be performance impact of using HTTP vs Shared Memory on localhost?
sand
@sand: I would guess little to none. But the only way to be sure is to profile it.
Billy ONeal
I expect shared memory + semaphores will be significantly more performant that TCP (even over the loopback.) However, especially if you must *also* support the remote-server scenario, TCP may be "good enough" and save you implementing both TCP (for the remote scenario) and shmem+IPC (for the local scenario.)
vladr
+1  A: 

You should have a look at the ASIO library, which is available either as a part of boost or as a standalone library, and provides you all you need to implement reliable and fast asynchronous services over a network.

jcayzac