Archive for July, 2009

User Agent

After a week to struggle with jquery (js framework) and nitrogen, I able to write some small web 2 applications. But it is appear that a trading client is more complex than the system!!!

First the web application not suite for a high reliable trading platform – few of trading softwares written in web.

Second, I want implement a push-technology not a polling one (use in my company Vb.net software). So it double my work.

user

Main idea is a User agent process. When a user login, a User agent which global register with username created.  The  User agent bond with Session so if user logout or session timeout, it will be destroyed. Next time, user must login again to create a new User agent. So a User agent represent for a login user.

With global register name, there is a unique user agent per a user existed. If the same user login from other computer, the current user agent kicked out. Current user logout with error message – login from other computer(like yahoo email).

Pages interact with User agent by subscribe an event. User agent will push events to subscribe pages. Then the page push event to user browser via comet connection.

Other method to interact with user agent is job. Job is a block process, User agent will stop handle other event until the job not completed nor timeout (or crash). Job also stopped  if user agent destroyed.

Leave a Comment

Time for client

I hated to write a web application; tons of javascript, html and css code – mostly for decorate a button or a form :)

Another thing is performance, web application is very very slow…

I found an awesome article about a guy push 1 million comet connections on a single mochiweb server. It is fucking amazing. A million comet connections mean 1 million concurrent active connections – it cost more resource than 1 million normal web requests which close connection after finish their job. There are 3 parts of the article – step by step solve the million connection problems. It’s interesting that most of tuning jobs are for Linux not erlang its self. Erlang born for huge numbers of concurrent processes.

http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1/

Another awesome thing is Nitrogen framework http://nitrogenproject.com

Nitrogen is pure erlang web 2 framework. You can code a web application like eat a piece of cake , they have a sample of comet chat room just 57 loc . Nitrogen support jquery as client, yaws or mochiweb as server and long-poll comet technical.

Of cause nitrogen can’t handle 1 million comet as mochiweb. It is complex framework and not optimize yet. But it save my ass for coding web application and I can patch nitrogen later for performance. Nitrogen also contain some interesting piece of code. Sync and mirror module allow migrate an erlang application from computer to computer automatically. Great, I can use it to write a code management for my application. I can update a node and whole system can work without more work.

Comments (1)

The whole picture

I draw a whole picture for my application.

Diagram1

Leave a Comment