Giter Club home page Giter Club logo

n2o's Introduction

N2O: Erlang Web Framework

Build Status

Features

  • Formatters: BERT, JSON, Binary or Custom
  • Protocols: Nitrogen, RoR, N2O
  • Endpoints: WebSocket, HTTP, REST
  • PubSub: MQS, GPROC
  • Templates: DTL
  • Sessions: STD and Autogenerated Logins
  • DOM Language: Nitrogen DSL, Erlang Shen
  • Speed: 15K req/s
  • Security: AES CBC 128
  • Samples: Skyline (DSL), Games (SPA)

Sample Page in DSL

-module(index).
-compile(export_all).
-include_lib("n2o/include/wf.hrl").

peer()    -> io_lib:format("~p",[wf:peer(?REQ)]).
message() -> wf:js_escape(wf:html_encode(wf:q(message))).
main()    -> #dtl{file="index",app=n2o_sample,bindings=[{body,body()}]}.
body() ->
    {ok,Pid} = wf:comet(fun() -> chat_loop() end),
    [ #panel{id=history}, #textbox{id=message},
      #button{id=send,body="Chat",postback={chat,Pid},source=[message]} ].

event(init) -> wf:reg(room);
event({chat,Pid}) -> Pid ! {peer(), message()};
event(Event) -> skip.

chat_loop() ->
    receive {Peer, Message} ->
       wf:insert_bottom(history,#panel{body=[Peer,": ",Message,#br{}]}),
       wf:flush(room) end, chat_loop().

And try to compare how this functionality would be implemented with your favourite language/framework.

Performance

We are using for measurement ab, httperf, wrk and siege, all of them. The most valuable storm created by wrk and it is not achieved in real apps but could show us the internal throughput of individual components. The most near to real life apps is siege who also make DNS lookup for each request. So this data shows internal data throughput by wrk:

Framework Enabled Components Speed Timeouts
PHP5 FCGI Simple script with two terms inside 5K timeouts
Nitrogen No sessions, No DSL, Simple template with two variable 1K no
N2O All enabled, sessions, Template, heavy DSL 7K no
N2O Sessions enabled, template with two variables, no DSL 10K no
N2O No sessions, No DSL, only template with two vars 15K no

Kickstart Bootstrap

To try N2O you just need to clone a N2O repo from Github and build. We use very small and powerful mad tool designed for our Web Stack.

$ git clone git://github.com/5HT/n2o
$ cd n2o/samples
$ ./mad deps compile plan repl

Now you can try: http://localhost:8000

LINUX NOTE: if you want to have online recompilation you should do at first:

$ sudo apt-get install inotify-tools

Support

  • IRC Channel #n2o on FreeNode 24/7
  • Official N2O Book HTML and PDF

Credits

  • Maxim Sokhatsky -- core, shen, windows
  • Dmitry Bushmelev -- endpoints, yaws, cowboy
  • Andrii Zadorozhnii -- elements, actions, handlers
  • Vladimir Kirillov -- mac, bsd, xen, linux support
  • Andrey Martemyanov -- binary protocols
  • Oleksandr Nikitin -- security
  • Anton Logvinenko -- doc
  • Roman Shestakov -- advanced elements, ct
  • Jesse Gumm -- nitrogen, help
  • Rusty Klophaus -- original author

OM A HUM

n2o's People

Contributors

5ht avatar doxtop avatar rilian avatar antonlogvinenko avatar proger avatar m-2k avatar romanshestakov avatar mamusr avatar b0oh avatar moiseev avatar sinasamavati avatar 23min avatar skolot avatar surik avatar lambdaterm avatar jl2 avatar programulya avatar jupp0r avatar ngocdaothanh avatar wizzard0 avatar srgibberd avatar artemeff avatar homeway avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.