[Openstack] Queue Service Implementation Thoughts

Curtis Carter curtis.carter at rackspace.com
Tue Mar 8 16:31:59 UTC 2011

Couple of questions.
Where did you come up with 300 bytes per message for ets?
When you say 2 threads for Erlang what do you mean?  Do you mean 2 schedulers and/or 2 run queues, Erlang processes, or Erlang vms.  

I wrote a basic queue using the queue module(double ended FIFO) that was handling around 526k a second with 100 clients on an old core2 duo laptop.  
200000 8 byte messages per client (I do not know how the queue module is implemented)
100 clients/queues
Was very unscientific in the front seat of my car while waiting on someone. NO HTTP
I know very apple/oranges here.  From what I've seen in the past Erlang does not pass other http servers until you hit a large amount of concurrent requests.  

On Mar 7, 2011, at 3:32 PM, Eric Day wrote:

> I ran the tests again to verify:
> 500k requests - 10 processes each running 50k requests.
>                time req/s     cs us sy id
> 2 thread/proc
>  echo c++      7.19 69541 142182 23 77  0
>  echo erlang   9.53 52465 105871 39 61  0
>  echo python   9.58 52192 108420 42 58  0
> 2 thread/proc
>  wsgi python  58.74 8512   18132 86 14  0
>  webob python 78.75 6349   13678 89 11  0
>  webmachine*  63.50 7874   11834 89 11  0
>  openstack    20.48 24414  49897 68 32  0
> cs/us/sys/id are from vmstat while running the tests.
> * webmachine degrades over time with long-lived, multi-request
>  connections. This number was estimated with 1000 requests per
>  connection. At 50k requests per connection, the rate dropped to
>  2582 req/s.
> As you can see I was able to reproduce the same numbers. If
> anyone would like to do the same, you can grab lp:burrow for the
> "openstack" Erlang application (compile and run ./start), webmachine
> is at https://github.com/basho/webmachine (you need to create a demo
> app and make sure you set nodelay for the socket options), and I've
> attached the python server and client (start 10 client processes when
> testing). Find me on irc (eday in #openstack) if you have questions.
> If we hit performance issues with this type of application, we'll
> probably hit them around the same time with both Erlang and Python
> (then we'll look to C/C++). Since most OpenStack developers are a lot
> more comfortable with Python, I suggest we make the switch. Please
> response with thoughts on this. I'll add a sqlite backend to the
> Python prototype and run some performance tests against that to see
> if any red flags come up.
> -Eric
> On Sat, Mar 05, 2011 at 10:39:18PM -0700, ksankar at doubleclix.net wrote:
>>   Eric,
>>      Thanks for your experimentation and analysis. Somewhat illustrates the
>>   point about premature optimization. First cut, have to agree with you and
>>   conclude that python implementation is effective, overall. As you said,if
>>   we find performance bottlenecks, especially as the payload size increases
>>   (as well as if we require any complex processing at the http server layer)
>>   we can optimize specific areas.
>>       Just for sure, might be better for someone else to recheck. That way
>>   we have done our due diligence.
>>   Cheers
>>   <k/>
>>     -------- Original Message --------
>>     Subject: [Openstack] Queue Service Implementation Thoughts
>>     From: Eric Day <eday at oddments.org>
>>     Date: Sat, March 05, 2011 4:07 pm
>>     To: openstack at lists.launchpad.net
>>     Hi everyone,
>>     When deciding to move forward with Erlang, I first tried out the Erlang
>>     REST framework webmachine (it is built on top of mochiweb and used
>>     by projects like Riak). After some performance testing, I decided to
>>     write a simple wrapper over the HTTP packet parsing built into Erlang
>>     (also used by mochiweb/webmachine) to see if I could make things a
>>     bit more efficient. Here are the results:
>>     Erlang (2 threads)
>>     echo - 58823 reqs/sec
>>     webmachine - 7782 reqs/sec
>>     openstack - 24154 reqs/sec
>>     The test consists of four concurrent connections focused on packet
>>     parsing speed and framework overhead. A simple echo test was also
>>     done for a baseline (no parsing, just a simple recv/send loop). As
>>     you can see, the simple request/response wrapper I wrote did get some
>>     gains, although it's a little more hands-on to use (looks more like
>>     wsgi+webob in python).
>>     I decided to run the same tests against Python just for comparison. I
>>     ran echo, wsgi, and wsgi+webob decorators all using eventlet. I ran
>>     both single process and two process in order to compare with Erlang
>>     which was running with two threads.
>>     Python (eventlet)
>>     echo (1 proc) - 17857 reqs/sec
>>     echo (2 proc) - 52631 reqs/sec
>>     wsgi (1 proc) - 4859 reqs/sec
>>     wsgi (2 proc) - 8695 reqs/sec
>>     wsgi webob (1 proc) - 3430 reqs/sec
>>     wsgi webob (2 proc) - 6142 reqs/sec
>>     As you can see, the two process Python echo server was not too far
>>     behind the two thread Erlang echo server. The wsgi overhead was
>>     significant, especially with the webob decorators/objects. It was
>>     still on par with webmachine, but a factor of three less than my
>>     simple request/response wrapper.
>>     A multi-process python server does have the drawback of not being
>>     able to share resources between processes unless incurring the
>>     overhead of IPC. When thinking about a horizontally scalable service,
>>     where scaling-out is much more important than scaling-up, I think
>>     this becomes much less of a factor. Regardless of language choice,
>>     we will need a proxy to efficiently hash to a set of queue servers in
>>     any large deployment (or the clients will hash), but if that set is a
>>     larger number of single-process python servers (some running on the
>>     same machine) instead of a smaller number of multi-threaded Erlang
>>     servers, I don't think it will make too much of a difference (each
>>     proxy server will need to maintain more connections). In previous
>>     queue service threads I was much more concerned about this and was
>>     leaning away from Python, but I think I may be coming around.
>>     Another aspect I took a look at is options for message storage. For
>>     the fast, in-memory, unreliable queue type, here are some numbers
>>     for options in Python and Erlang:
>>     Raw message = key(16) + ttl(8) + hide(8) + body(100) = 132 bytes
>>     Python list/dict - 248 bytes/msg (88% overhead)
>>     Python sqlite3 - 168 bytes/msg (27% overhead)
>>     Erlang ets - 300 bytes/msg (127% overhead)
>>     The example raw message has no surrounding data structure, so it is
>>     obviously never possible to get down to 132 bytes. As the body grows,
>>     the overhead becomes less significant since they all grow the same
>>     amount. The best Python option is probably an in-memory sqlite table,
>>     which is also an option for disk-based storage as well.
>>     For Erlang, ets is really the only efficient in-memory option (mnesia
>>     is built on ets if you're thinking of that), and also has a disk
>>     counterpart called dets. The overhead was definitely more than I was
>>     expecting and is less memory efficient than both Python options.
>>     As we start looking at other stores to use, there are certainly more
>>     DB drivers available for Python than Erlang (due to the fact that
>>     Python is more popular). We'll want to push most of the heavy lifting
>>     to the pluggable databases, which makes the binding language less of
>>     a concern as well.
>>     So, in conclusion, and going against my previous opinion, I'm starting
>>     to feel that the performance gains of Erlang are really not that
>>     significant compared to Python for this style of application. If
>>     we're talking about a factor of three (and possibly less if we can
>>     optimize the wsgi driver or not use wsgi), and consider the database
>>     driver options for queue storage, Python doesn't look so bad. We'll
>>     certainly have more of a developer community too.
>>     We may still need to write parts in C/C++ if limits can't be overcome,
>>     but that would probably be the case for Erlang or Python.
>>     What do folks think?
>>     -Eric
>>     _______________________________________________
>>     Mailing list: https://launchpad.net/~openstack
>>     Post to : openstack at lists.launchpad.net
>>     Unsubscribe : https://launchpad.net/~openstack
>>     More help : https://help.launchpad.net/ListHelp
> <speed_client.py><speed_server.py>_______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to     : openstack at lists.launchpad.net
> Unsubscribe : https://launchpad.net/~openstack
> More help   : https://help.launchpad.net/ListHelp

Confidentiality Notice: This e-mail message (including any attached or
embedded documents) is intended for the exclusive and confidential use of the
individual or entity to which this message is addressed, and unless otherwise
expressly indicated, is confidential and privileged information of Rackspace.
Any dissemination, distribution or copying of the enclosed material is prohibited.
If you receive this transmission in error, please notify us immediately by e-mail
at abuse at rackspace.com, and delete the original message.
Your cooperation is appreciated.

More information about the Openstack mailing list