[OBS: this is a repost from http://blog.monkey-project.com/2012/03/13/duda-web-services-framework-for-monkey/]
There is one fact: we are in exciting times for the project. Our HTTP core is consolidated since a while ago, it works in non-blocking mode, it has a nice indented configuration model and provide an advanced API to extend the core behavior, through this we support different behaviors by layers like IPv4, IPv6, SSL encription, security by subnets, basic auth, shell, log writer, etc.
There is a common question from people around the project: “where are you going ?” and the answer is: do you see that embedded Linux Box ?, there’s where we go. Common web servers lack of performance for embedded systems, most of them have focused in high production environments. our focus is different.
Our tech world is service oriented and i would say that implemented through a fat HTTP software stack, simple things are done in scripting languages that requires a process context or even be ran in a JVM environment, that is not lightweight and requires extra resources to be scalable. If you plan to implement a web service for embedded you should start forgetting about Java and PHP and think in lightweight options. Please Google a little about the options available and then continue reading here.
I am pleased to announce Duda, a web services framework built on top of Monkey, is event-driven oriented and expose a friendly C API for the implementation of web services. It goals are performance and easy deployment. It target Linux embedded devices based on ARM (x86 and x64). It implementations is licensed under the LGPL so it allows to link your private web service with our GPL product.
There are many mechanisms to achieve a great performance, but talking in an embedded context the primary answer will be: do it in C. Duda and it’s API is made for C developers looking for an event-driven framework supporting URI maps and callbacks. We define an URI map as follows:
- webservice_name: the web service name, a short name like ‘myapp’
- interface: an interface group a set of methods, think it like a main class, mostly for ordering purposes.
- method: a routine who take cares of the main request, this is mapped internally by a callback and is able to send response data
- param: parameters passed through the URI, it’s limited to 16 parameters per request.
If you desire to pass a huge amount of data, you can consider using the POST HTTP method, Duda supports JSON in case you wanted to use it.
Performance: Duda v/s NodeJS
For the following tests i have created a NodeJS script with 5 workers (same as monkey) which replies a “Hello World!\n” string (13 bytes)
Requests per second
I have done the easiest bechmark test with Apache benchmark: 50000 request with 100 concurrents hitting the hello world of each server:
Total transferred bytes
Something is wrong here, why Monkey transferred almost twice bytes than NodeJS ?, looking at the response header we can see that NodeJS is being tricky, its not sending the HTTP Date header, i expected the framework do this by its own.
Its importan to know how much memory is using each service when is running, check the results and
A graphical comparison of Memory usage:
Duda since it’s beginning is hitting a huge performance, is ready for embedded due to it lightweight nature. We are hard working to implement required features such as Redis, Memcache, MySQL and others. All of this is part of Monkey v1.0 so stay tuned. We keep rocking, and now harder
- You can get the Apache Benchmark results and code for each services from here