My idea is to build a simple chat application for iOS and Android. In any case, my question is related to the server-side. The best option to do a chat application, from what I've read, is to build a socket. Referring to the database, my intention is to use MySQL, which may also be important to take into account in order to choose one of the possibilities.
My question is, in terms of scalability, speed and security, which is the best option: building a socket with Python using Twisted or with NodeJS using Socket.IO?
I guess that there may be other possibilities to build an efficient socket, but by now I'm considering this two. I'd really appreciate it if you could give me some advice.
Key Differences between WebSocket and socket.ioIt provides the Connection over TCP, while Socket.io is a library to abstract the WebSocket connections. WebSocket doesn't have fallback options, while Socket.io supports fallback. WebSocket is the technology, while Socket.io is a library for WebSockets.
js - Using socket.io is broadcasting the same efficiency as sending a message to every client - Stack Overflow.
Socket.IO was created in 2010. It was developed to use open connections to facilitate realtime communication, still a relatively new phenomenon at the time. Socket.IO allows bi-directional communication between client and server.
JS, Socket.IO enables asynchronous, two-way communication between the server and the client. This means that the server can send messages to the client without the client having to ask first, as is the case with AJAX.
Comparing Twisted and Socket.io is comparing apples to a truck carrying apples. Twisted is a library that provides event oriented programming functionality to Python. In javascript that's merely javascript itself (be it node.js or a web browser or even rhino).
A more apt comparison is to compare Socket.io on node.js with Socket.io on Python. While there is one main implementation of a socket.io server on node there are several for Python:
https://github.com/MrJoes/tornadio
https://github.com/abourget/gevent-socketio
https://github.com/stephenmcd/django-socketio
(taken from the socket.io wiki: https://github.com/learnboost/socket.io/wiki)
You can even implement your own socket.io in Python using Twisted if you want. The socket.io protocol is documented here: https://github.com/LearnBoost/socket.io-spec. But that would defeat the purpose of socket.io - it abstracts away low level details of real time web communications and allows you to concentrate on writing your business logic.
On the client side you'd deploy the same socket.io script to the browser regardless of what language you decide to write the server in.
With regards to which language to choose: my rule of thumb is choose the language you're most comfortable with. You're going to have enough problems debugging your business logic. Don't complicate it by using an unfamiliar language.
Both languages are battle hardened (yes, even node.js which is surprising considering how young it is). Python for example is used in production on such high traffic services as Dropbox. Node is currently in use on such high traffic services as LinkedIn mobile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With