uwsgi + gevent + socket.io

713 views
Skip to first unread message

Max Wolter

unread,
Oct 24, 2013, 12:46:40 PM10/24/13
to gevent-...@googlegroups.com
Hello dear Alexandre.

I just took a quick peak at your Gplus profile and I'm delighted to see that you are also a Bitcoin enthusiast.

We are currently trying to set up a platform to offer various Bitcoin services and we would like to use socket.io as a means to implement Web Socket functionality.

However, our back-end is written in C++ and uses SCTP to interface with our other modules. In order to connect the socket.io server to the back-end server, we would thus need a SCTP library. Unfortunately, this is not offered in JavaScript/node.JS.

On the other hand, there are decent SCTP bindings available for Python, which is why we are looking at your gevent-socketio library. Unfortunately, the documentation available on setting it up is still sparse. We are looking for an efficient solution and are currently not sure what the best way to deploy your work would be.

We have already chosen uwsgi + gevent to implement the user API and it seems like the only Python choice out there able to keep up with node.JS performance-wise. Our question is thus whether it's possible to use your gevent-socketio implementation to run on top of the uwsgi web server? The uwsgi server can be run in gevent mode, which makes it single-threaded, using gevent as it's loop engine. It would be ideal if this setup would also work for our socket.io server. This requires gevent 1.0 to be used, though.

If this is not possible, do you have any recommendations on a solid stack to deploy gevent-socketio with? Do you have any benchmarking data for node.JS vs gevent-socketio as a server?

We would greatly appreciate your input.

Best regards,
Max Wolter.

Max Wolter

unread,
Oct 24, 2013, 12:49:36 PM10/24/13
to gevent-...@googlegroups.com
Oh, and as an additional note, the server will be used to handle Web Socket functionality exclusively. Normal HTTP requests will be sent to a different server.

Regards,
Max.

Damian Dimmich

unread,
Apr 24, 2014, 12:41:44 PM4/24/14
to gevent-...@googlegroups.com
Hi,

I've spent quite a while trying to get a similar setup to work today - uwsgi + gevent running pyramid with wsgi and socketio.  The pyramid bits work quite happily but I can't seem to get the socketio part to work.  I've tried:

from socketio.server import SocketIOServer
from pyramid.paster import get_app
from gevent import monkey; monkey.patch_all()
import uwsgi

def application(environ, start_response):

    app = get_app(uwsgi.opt['inifile'])

    print 'Listening on port http://0.0.0.0:8080 and on port 10843 (flash policy server)'


    return SocketIOServer(('127.0.0.1',9090 ), app,
        resource="socket.io", policy_server=True,
        policy_listener=('0.0.0.0', 10843))

However that doesn't return a wsgi app and doesn't work and:

#load paster app
from pyramid.paster import setup_logging
from paste.deploy import loadapp
setup_logging(uwsgi.opt['inifile'])
application =  loadapp('config:%s' % (uwsgi.opt['inifile'])  )

doesn't use the correct server I have the following in my production.ini which gets ignored I think:

[server:main]
use = egg:gevent-socketio#paster

and the uwsgi config is as follows:

[uwsgi]uwsgi
socket = 127.0.0.1:9090
http-websockets = truen, start_response):
route = ^/socket.io uwsgi:127.0.0.1:9090/socket.io
chdir = /data/faploid-webpt['inifile'])
file = %(chdir)/faploid.wsgi
master = truestening on port http://0.0.0.0:8080 and on port 10843 (flash policy server)'
processes = 8
threads = 2
stats = 127.0.0.1:9191ver(('127.0.0.1',9090 ), app,
pythonpath = %(chdir)/lib/python2.7/site-packages:%(chdir)
virtualenv = %(chdir)er=('0.0.0.0', 10843))
plugins = python, gevent
inifile = %(chdir)/%s
gevent = true                                                                                                                                                                                                            
async = 10

Any idea where I am going wrong?

Thanks,
Damian
Reply all
Reply to author
Forward
0 new messages