Webdis, an HTTP interface to Redis

1,848 views
Skip to first unread message

Nicolas Favre-Félix

unread,
Dec 28, 2010, 3:14:33 PM12/28/10
to redi...@googlegroups.com
Hello all,

After a discussion about HTTP interfaces to Redis on IRC, I have put together a simple web server exposing Redis functions over HTTP: https://github.com/nicolasff/webdis
Webdis is only a week old, and I'm not really sure what will come of it; I would like this announcement to bring comments and suggestions for this new project, and I hope people will get interested.

The basic interface is the following: /COMMAND/arg0/arg1/.../argN, returning a JSON object with the command as a key and Redis' response as a value. A few examples:

{"SET":[true,"OK"]}
{"GET":"world"}
{"PING":[true,"PONG"]}

The raw Redis output is available by appending the query string "?format=raw" to the command:
*2
$3
abc
$3
def

So far, the following features have been implemented:
  • GET and POST commands.
  • JSON output by default, optional JSONP parameter.
  • Raw Redis 2.0 protocol output with ?format=raw
  • HTTP 1.1 pipelining (measured over 50,000 http requests per second on a desktop Linux machine with Apache Benchmark).
  • Connects to Redis using a TCP or UNIX socket.
  • Restricted commands by IP range (CIDR subnet + mask), returning 403 errors for unauthorized clients.
  • Possible Redis authentication in the config file.
My main priorities are client-side timeouts and a working pub/sub system, making it a Comet server using redis pub/sub channels. Adding support for Web Sockets would be pretty cool too.
Webdis is pretty fast so far, thanks to the libevent HTTP implementation.

I look forward to seeing people play with it and I welcome all comments and suggestions; I'm having fun working on it.

Nicolas

Salvatore Sanfilippo

unread,
Dec 28, 2010, 3:25:59 PM12/28/10
to redi...@googlegroups.com
2010/12/28 Nicolas Favre-Félix <n.favr...@gmail.com>:

> Hello all,
> After a discussion about HTTP interfaces to Redis on IRC, I have put
> together a simple web server exposing Redis functions over
> HTTP: https://github.com/nicolasff/webdis
> Webdis is only a week old, and I'm not really sure what will come of it; I

Hello Nicolas,

this looks a cool project. I think there is definitely a need for this
piece of software in many Redis web-related use cases. I'm not sure
how the problem with access control can be solved, but I guess this is
something that can be figured out in the process.

I've some idea about how to implement easy ACLs for the exported
functionalities.
One is of course the ability to just allow a list of commands.

I feel like that the other layer of authentication should be at key
level. That is, if the request comes with a token and this token
matches the "authentication token" for a given key, than the request
is processed otherwise is not.

But probably there are better ways...

I'm really curious about what people will do with Webdis, but I'm
pretty sure such an interface can surely help to scale web
applications where most of the things happen (or can be made
happening) on the javascript side of the application, in the web
client, just processing data we can directly get from Redis via the
HTTP layer.

Cheers,
Salvatore

--
Salvatore 'antirez' Sanfilippo
http://invece.org

"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele

Jeremy Zawodny

unread,
Dec 28, 2010, 4:44:28 PM12/28/10
to redi...@googlegroups.com
Nicolas,

I don't know if this was inspired by the IRC discussion I was part of a few weeks ago or not, but that's awesome.  I've been wanting to see something like this for a while now and never had the time to attack it.  I look forward to trying it out very soon.

Thanks!

Jeremy

2010/12/28 Nicolas Favre-Félix <n.favr...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.

Jonathan Leibiusky

unread,
Dec 28, 2010, 6:33:00 PM12/28/10
to redi...@googlegroups.com
This is very cool!
Does it support pub/sub?

Great job!

Jonathan

>> - GET and POST commands.
>> - JSON output by default, optional JSONP parameter.
>> - Raw Redis 2.0 protocol output with ?format=raw
>> - HTTP 1.1 pipelining (measured over 50,000 http requests per second on


>> a desktop Linux machine with Apache Benchmark).

>> - Connects to Redis using a TCP or UNIX socket.
>> - Restricted commands by IP range (CIDR subnet + mask), returning 403
>> errors for unauthorized clients.
>> - Possible Redis authentication in the config file.


>>
>> My main priorities are client-side timeouts and a working pub/sub system,
>> making it a Comet server using redis pub/sub channels. Adding support for
>> Web Sockets would be pretty cool too.
>> Webdis is pretty fast so far, thanks to the libevent HTTP implementation.
>>
>> I look forward to seeing people play with it and I welcome all comments
>> and
>> suggestions; I'm having fun working on it.
>>
>> Nicolas
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Redis DB" group.
>> To post to this group, send email to redi...@googlegroups.com.
>> To unsubscribe from this group, send email to

>> redis-db+u...@googlegroups.com<redis-db%2Bunsu...@googlegroups.com>

agentzh

unread,
Dec 28, 2010, 10:02:07 PM12/28/10
to redi...@googlegroups.com
2010/12/29 Nicolas Favre-Félix <n.favr...@gmail.com>:

> Hello all,
> After a discussion about HTTP interfaces to Redis on IRC, I have put
> together a simple web server exposing Redis functions over
> HTTP: https://github.com/nicolasff/webdis
> Webdis is only a week old, and I'm not really sure what will come of it; I
> would like this announcement to bring comments and suggestions for this new
> project, and I hope people will get interested.

Do you know ngx_redis2? ;)

https://github.com/agentzh/redis2-nginx-module

It seems to me that these REST interfaces can be easily configured
using ngx_redis2 (or possibly combined with ngx_lua) :) And yeah,
performance may not be that great as your simple http server
implementation but we can have many more functionalities offered by
the nginx ecosystem :)

Cheers,
-agentzh

Peter Mescalchin

unread,
Dec 28, 2010, 10:43:55 PM12/28/10
to Redis DB
Fantastic work! Sorta makes Redis a bit like CouchDB - and I guess in
some way could make it easier to write super lightweight client access
libs if the need arises.

Pedro Melo

unread,
Dec 29, 2010, 2:01:31 AM12/29/10
to redi...@googlegroups.com
Hi,


On Tue, Dec 28, 2010 at 11:33 PM, Jonathan Leibiusky <iona...@gmail.com> wrote:
> This is very cool!
> Does it support pub/sub?

See the README, its on the todo list.

Bye,
--
Pedro Melo
http://www.simplicidade.org/
xmpp:me...@simplicidade.org
mailto:me...@simplicidade.org

Vladimir Dronnikov

unread,
Dec 29, 2010, 3:33:25 AM12/29/10
to redi...@googlegroups.com
Would be nice to employ https://github.com/kriszyp/rql to bring
ability to specify complex queries.

--Vladimir

Mike Shaver

unread,
Dec 29, 2010, 3:23:39 PM12/29/10
to redi...@googlegroups.com
2010/12/28 Nicolas Favre-Félix <n.favr...@gmail.com>:

> I look forward to seeing people play with it and I welcome all comments and
> suggestions; I'm having fun working on it.

This looks pretty interesting as a way to quickly integrate redis
storage into apps -- not that the redis client interfaces tend to be
that hard to work with, but for direct-to-browser stuff this and the
nginx work will be helpful.

Do you plan any support for If-Modified-Since? In a bunch of my
redis-backed toys the limiting factor on responsiveness is network
bandwidth, and the only thing faster than sending back data from redis
is not sending it back at all! To do it well, you'd want redis to
track mtime per-key, probably, so that your I-M-S calculations could
just be against max(mtime(key1), mtime(key2), mtime(keyN)).

I have been meaning to sketch a proposal for TOUCH $key, MTIME $key,
MTIMEMAX $key1 $key2 ... $keyN, and a sort option on key-mtime, but
haven't had the round tuits. Thanks for the reminder. :-)

Mike

Nicolas Favre-Félix

unread,
Dec 29, 2010, 6:06:14 PM12/29/10
to redi...@googlegroups.com
Thanks for the kind words and the suggestions, it's all very much appreciated.

Salvatore, there are indeed many ways to add better ACLs here. I'll add at least HTTP Basic Auth first, and am open to suggestions. Basic Auth is not very good, but it is simple and it allows commands to be sent without a preliminary handshake. The basic idea for now is to allow or disable commands by name + subnet & mask; it is probably going to change as a better solution emerges.

Jeremy, I've seen this kind of API suggested several times on IRC, both by you and Salvatore. It is very clean; I'm not very fond of the fact that the HTTP GET verb is not idempotent, but I guess that's the price to pay for this kind of API candy. I'd be very interested to hear your comments.

Mike, If-Modified-Since would be very interesting to have, but I'm not sure how that could be done without patching redis. Webdis does not actually embed Redis, but only connects to it.
That said, an Etag could be added in order to save on the transfer: it would just be a hash of the value sent by Redis. What do you think?

Cheers,
Nicolas

Abdullah Elzayat

unread,
Sep 30, 2022, 1:23:59 PM9/30/22
to Redis DB
Hello @ Nicolas Favre-Félix
Can you please provide an example of POST request with lpush command?
Or a more generic POST example.
I can't find any in the docs, and I'm stuck, can't figure out how to format the body and the URI.

Pierre Chapuis

unread,
Oct 1, 2022, 5:13:45 AM10/1/22
to Redis DB
Did you realize the message you are answering is 12 years old ? :)

Oscar Besga

unread,
Oct 9, 2022, 3:11:27 PM10/9/22
to Redis DB
Well, the project has been updated 8 months ago.
And it seems a neat project, kudos to the developers

Reply all
Reply to author
Forward
0 new messages