Giter Club home page Giter Club logo

terminator's Introduction

Terminator

sinatra开发框架模板

根目录

默认根目录/是解析README.md内容,作为首页.

例子

代码位置 lib/terminator/app/controller/home.rb

/home

这个例子约定了作为webservice的返回数据结构

{:status => 0, :msg => 'ok', :data => [1,2,3]}

/home/ansync

这个例子实现了异步长连接的http请求,基于eventmachine,

A -> Server
B -> Server
.      .
.      .
.      .
A <- Server
B <- Server

用curl测试下

saimatoMacBook-Pro:terminator cuizheng$ curl -viN localhost:7000/home/async
* About to connect() to localhost port 7000 (#0)
*   Trying ::1... Connection refused
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 7000 (#0)
> GET /home/async HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:7000
> Accept: */*
> 
< HTTP/1.1 200 OK
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Content-Type: text/html;charset=utf-8
< Connection: close
< Server: thin 1.5.0 codename Knife
< 
* Closing connection #0
2013-03-28 17:18:20 +0800Someone comming.2013-03-28 17:18:30 +0800

ab性能测试结果如下

ab -c 100 -n 100 http://218.108.172.21:7000/home/async
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 218.108.172.21 (be patient).....done


Server Software:        thin
Server Hostname:        218.108.172.21
Server Port:            7000

Document Path:          /home/async
Document Length:        1634 bytes

Concurrency Level:      100
Time taken for tests:   10.259 seconds
Complete requests:      100
Failed requests:        99
   (Connect: 0, Receive: 0, Length: 99, Exceptions: 0)
Write errors:           0
Total transferred:      104900 bytes
HTML transferred:       84200 bytes
Requests per second:    9.75 [#/sec] (mean)
Time per request:       10259.021 [ms] (mean)
Time per request:       102.590 [ms] (mean, across all concurrent requests)
Transfer rate:          9.99 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    2   0.6      2       3
Processing: 10151 10181  44.5  10156   10254
Waiting:       86  113  17.8    114     136
Total:      10155 10184  44.1  10159   10256

Percentage of the requests served within a certain time (ms)
  50%  10159
  66%  10160
  75%  10256
  80%  10256
  90%  10256
  95%  10256
  98%  10256
  99%  10256
 100%  10256 (longest request)

平均每个请求10.259秒,而代码中是延迟10秒才返回的,可以看到100个并发并没有发生阻塞,性能没问题。

Contributing to terminator

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2012 zheng.cuizh. See LICENSE.txt for further details.

terminator's People

Contributors

charlescui 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.