GithubHelp home page GithubHelp logo

kernelsauce / turbo Goto Github PK

View Code? Open in Web Editor NEW
518.0 40.0 87.0 4.63 MB

Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses.

Home Page: http://turbo.readthedocs.io/

License: Apache License 2.0

Lua 97.42% Makefile 1.22% Batchfile 0.77% Shell 0.60%
lua luajit api-server network http

turbo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

turbo's Issues

Async DNS

getaddrinfo blocks, we need an alternative.

Request handler methods does not recieve multiple arguments (routes).

When defining a route like "/(%d)/(%d)$" request handler methods only get the first argument.

Test Case:

local turbo = require("turbo")

local TestHandler = class("TestHandler", turbo.web.RequestHandler)
function TestHandler:get(a1, a2)
    print("a1 == ", a1)
    print("a2 == ", a2)
    assert(a1 ~= nil)
    assert(a2 ~= nil)
    self:write("..")
end

local application = turbo.web.Application:new({
    {"/(%d)/(%d)$", TestHandler}
})

application:listen(8888) 
turbo.ioloop.instance():start()

turn off log

how to trun off the log output when ab test,

luajit helloworld.lua
ab -n 100000 -c 500 -k 127.0.0.1:8888/
[D 2013/07/07 12:39:58] [ioloop.lua] Uncaught error in handler. /usr/local/share/lua/5.1/turbo/iostream.lua:455: Error when reading from socket 7. Errno: 104. Connection reset by peer
stack traceback:
    /usr/local/share/lua/5.1/turbo/ioloop.lua:120: in function </usr/local/share/lua/5.1/turbo/ioloop.lua:118>
    [C]: in function 'error'
    /usr/local/share/lua/5.1/turbo/iostream.lua:455: in function '_read_from_socket'
    /usr/local/share/lua/5.1/turbo/iostream.lua:476: in function '_read_to_buffer'
    /usr/local/share/lua/5.1/turbo/iostream.lua:397: in function '_handle_read'
    /usr/local/share/lua/5.1/turbo/iostream.lua:313: in function '_handle_events'
    /usr/local/share/lua/5.1/turbo/iostream.lua:601: in function 'ioloop_fd_callback'
    /usr/local/share/lua/5.1/turbo/ioloop.lua:124: in function </usr/local/share/lua/5.1/turbo/ioloop.lua:123>
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1/turbo/ioloop.lua:133: in function '_run_handler'
    /usr/local/share/lua/5.1/turbo/ioloop.lua:352: in function 'start'
    httpclient.lua:58: in main chunk
    [C]: at 0x00404180

[root@localhost libuv-lua-http-server]# grep model /proc/cpuinfo 
model       : 58
model name  : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
model       : 58
model name  : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
model       : 58
model name  : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
model       : 58
model name  : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
[root@localhost libuv-lua-http-server]# grep Total /proc/meminfo 
MemTotal:        7941300 kB
SwapTotal:       8216568 kB
VmallocTotal:   34359738367 kB
HugePages_Total:       0

[root@localhost libuv-lua-http-server]# ab -n 100000 -c 500 -k 127.0.0.1:8888/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        Turbo
Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /
Document Length:        9 bytes

Concurrency Level:      500
Time taken for tests:   15.975 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Non-2xx responses:      100000
Keep-Alive requests:    100000
Total transferred:      17500000 bytes
HTML transferred:       900000 bytes
Requests per second:    6259.61 [#/sec] (mean)
Time per request:       79.877 [ms] (mean)
Time per request:       0.160 [ms] (mean, across all concurrent requests)
Transfer rate:          1069.76 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       7
Processing:     1   80  38.2     90     209
Waiting:        1   80  38.2     90     209
Total:          1   80  38.2     90     209

Percentage of the requests served within a certain time (ms)
  50%     90
  66%     99
  75%    111
  80%    114
  90%    119
  95%    125
  98%    141
  99%    148
 100%    209 (longest request)

timeout is not available,when site was blocked(china gfw).

     local res = coroutine.yield(
        turbo.async.HTTPClient:new():fetch("http://search.twitter.com/search.json",
        {
            params = {
                q=search,
                result_type="mixed"
            },
            request_timeout = 3,
            connect_timeout = 3,
        }))

    if (res.error) then
        error(turbo.web.HTTPError:new(500, res.error.message))
    end

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.