Last time I launched my site on the ARM server from GlobalTel , and now I decided to write a project with 0 for this server.
It turned out this: habrachat.org . Small details under the cut.
Motivation
I wanted to load the ARM server with something easy, such a task where powerful x86 cores would be unnecessary. That's why I chose the asynchronous tornado server and the classic chat task.
I have not seen the chat for habrahabr. There is IRC, but I am there less and less, and I see people less often there.
I did not find a ready, simple chat on tornado + redis with room support. In general, for this bundle and tornado in particular, there are very few examples of the finished chat. In addition, these chats could not work on several kernels at once (only one instance).
')
Implementation
Components took simple nginx (WebsocketProxy), Tornado (WebSocket), tornado-redis, Redis. On the bootstrap + dojo client.
Authorization implemented through the ulogin service for speed of development. And in general, convenient service.
Text formatting implemented through bbcode library for python.
At first I did everything in one day and quite simply (where it is 300 lines), but it worked only in one instance. When I decided to make synchronization between instances, I suffered. As a result, the code has grown to 540 lines.
If sending messages to a user is a fairly simple task and is described everywhere, then sending a message to a neighboring chat room (instance) is already more difficult. Every “chat” I sign in redis on the same channel, and in a separate connection (as this is a blocking operation). When you turn on each "chat" sends a request to inform all of its users, all who receive this message also send their lists to everyone. In the future, I send the created message not only to users of a specific “chat” but also in all the other “chats” where a special callback function works. There are a lot of details, it is better to watch the code immediately.
The code itself is github.com/stalkerg/habrachat . There are a lot of mistakes there, many not beautiful approaches, so that if you find something, write on gitahb or push patches (wrote in a hurry and on the result). In addition, if I like the idea, I will develop it.
Addition
The Ubuntu kernel for ARM is built only with a basic set of netfilters, which is why you cannot even port a port. As a result, I collected nginx from source and proxy WebSocket on it. :(
Recently, GlobalTel had an accident and after the light was turned off, the server lost time at 0, that is, 73 year Probably ARM has this problem. I wondered for a long time why my ssl is buggy wherever possible.
PS If really it will be necessary for someone, then the service will grow into features and other things, and the crutches will be removed. Write in the comments your wishes.
PS2 I hope the effect will not drop the poor 4th nuclear ARM server.