I'm assuming here that the scaling you're looking for is large numbers
of concurrent TCP connections, more than large numbers of messages per
second.
Yes, that´s right!
But you can also scale to multiple cores and/or servers by
putting a simple TCP load balancer in front of your server(s). 'pen' is
a suitable software load-balancer, or you can buy lots of different
hardware appliances.
Okay, but this seems to me not to be the "standard way". It would be
better if I will use standard technologies, so other people could easily
maintain it, like an Apache webserver. But this is a good alternative!
And with EventMachine it is easy to set up a persistent SSL connection?
I'm not sure, you'd have to look for samples in the eventmachine
distribution and/or ask on an EventMachine list. But I would strongly
expect it has been done before.
Okay, I will look.
With a simple TCP socket server like you already have, it's easy to turn
it into an SSL server. For example, there is code in ruby-ldapserver
which does this (look at startssl in connection.rb and ssl_prepare in
server.rb)
That seems easy, easier than expected. That's all? Only 10-15 lines of
code to establish a SSl connection? Wow.
Okay, I could build up an apache webserver with for example phusion
passenger which enables the ssl security and the persistent connection.
And then I use Rack to get the requests and I can send the responses
back to the client. Is that right?
Yes. And for initial testing, you can run the rack app directly under
mongrel or thin or even webrick (rackup will start these servers for
you)
Okay, I read: "One popular configuration is to run Apache 2.2 as a load
balancer using mod_proxy_balancer in conjunction with several Mongrel
instances, with each Mongrel instance running on a separate port. This
is something that can be configured very easily using the
mongrel_cluster management utility. Apache can divide the incoming
requests among the available Mongrel processes, and, with careful
configuration, can even serve static content itself without having to
delegate to Mongrel.
For those who wish to avoid Apache altogether, it is possible to deploy
a Mongrel cluster with an alternative web server, such as nginx or
lighttpd, and a load balancer of some variety such as Pound or a
hardware-based solution." (wikipedia)
Do you think that is a good idea to do this?
Perhaps I will build up an Apache webserver with one Mongrel webserver
with Rack and my ruby scripts on one hardware server. This must be
possible?!
If I will need more webserver, then I buy a new hardware server, install
mongrel with my application and that's fine. But isn't it a problem with
the database if I only have one database and several webserver which
connect/read/write?
But how do I call the server from the
client? Is it a POST HTTP Request with the JSON message in his body?
Yes. And you'd send back an application/json response with the JSON
message in the body.
Okay, that would be perfect.
Note that HTTP limits you to exactly one response per request. That is,
the server can't send back asynchronous unsolicited responses to the
client. If you want to do that with HTTP, you'd have to get the client
to send a request and block waiting for a response (aka 'COMET') or poll
periodically.
Does that mean, the client establish a connection and only(!) if the
client requests something, there will be one response from the server?
So, it is not possible that the server send a message without(!) a
request from the client?
Thanks a lot and best regards!
···
--
Posted via http://www.ruby-forum.com/\.