2

Greetings, I have a large piece of software developed in Eiffel. It is possible to use this code from C++, but it loads Eiffel runtime, and I can't trust the Eiffel code and runtime to be thread safe, when accessed by multiple threads from C++

I need to turn this native code into a service, but I would like to scale to multiple servers in case of high load. I don't want to delegate the scaling aspect to Eiffel code & runtime, so I'm looking into wrapping this code with existing scalability options.

Is there anything under Apache web server that'd let me provide thread safe access to this chunk of code? How about a pool of Eiffel code instances? What I have in mind is something like this:

[lots of client requests over network] ---> [Some scalable framework] --> [One or more instances of expensive to create Eiffel code]

I'd like the framework to let me wrap multiple instances of expensive chunks of code and I'd like to scale this up just like a web farm, by adding more machines.

Best Regards

Seref

mahonya
  • 9,247
  • 7
  • 39
  • 68
  • 1
    Any particular reason why you want to use Apache? Or is another framework equally suited? – Fred Foo Mar 01 '11 at 11:40
  • It is a well known, tested and mature, multi platform web server. It can scale via load balancing. Any other framework that provides these is more then welcomed. – mahonya Mar 01 '11 at 12:21
  • @user238517: there are different degrees of thread-safety, do you meant that the Eiffel code using global variables whose access is not thread-safe or that one object cannot be accessed safely by multiple threads ? In your case, the latter is not an issue as long as the C++ workers do not share Eiffel objects between them. – Matthieu M. Mar 01 '11 at 13:34
  • @Matthieu: my problem is that the behaviour of Eiffel runtime, which you need to initialize before you call any Eiffel code from C++, is undefined in case of multiple C++ threads accessing it. Thread safety becomes a requirement for the whole Eiffel runtime and code running on it. – mahonya Mar 01 '11 at 23:13
  • @user238517: okay, so it's the former --> shared global state (the runtime) that is not thread-safe, then @larsmans solution looks promising :) – Matthieu M. Mar 02 '11 at 07:24

1 Answers1

2

If you're not tied to Apache but any other framework would suffice, I suggest you check out the ZeroMQ message passing framework. Its ZMQ_PUSH/ZMQ_PULL model with zmq_tcp transport seems to do what you want.

Your setup would be something like: one "master" process servicing outside requests (in any language/platform, perhaps an Apache mod) and a runtime-configurable number of C++ worker processes that call into Eiffel code and push results back.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836