2010/06/18


githubの中の人が書いた、node.js上で動くHTTP対話コンソールアプリ「http-console」をGoで書いてみた。
mattn知ってる人なら、だいたい名前が想像出来るかな...
そう。

http-gonsole


かっこ悪い?しるか

mattn's http-gonsole at master - GitHub

peak HTTP like a local. (the simple, intuitive HTTP console, golang version)

http://github.com/mattn/http-gonsole
使い方はhttp-consoleと同じにしてあります。node.js版も試してみたんですが、いかんせんインストール面倒くさい(コンパイル重い)し、http-consoleくらいの機能の割にはnode.jsは規模が大きすぎる。
最近go言語にハマってるってところもあったので書いてみました。
インストールにはreadline-goが必要です。
あと、コンテンツがJSONだった場合での色付き表示はサポートしていませんが、フツーに便利です。
http-gonsole
接続元の情報でCookie作ってるかもしれないので、一応隠しとく。
Cookieにも対応してます。
あと、あれだな。「POST!」コマンドあたりでPOSTデータをエディタで編集出来る機能が欲しいな。
Posted at by



2010/04/12


まぁ、まだ途中ですが...
/lang/lua/webservice-simplua
そこの君!名前がダサイとか言わない!
これを使うとflickr_echo.plのサンプルが local ws = require('webservice.simplua')

local api = ws.new({
    base_url = 'http://api.flickr.com/services/rest',
    params = {
        api_key = 'your_api_key'
    }
})

local ret  = api.get({
    method = 'flickr.test.echo',
    name = 'value'
})

local dom = ret.parse_xml()
print(dom:select("name")[1]:text()) -- "value"
こんな感じに書ける様になります。
まだ、getメソッドの第2引数でpathを指定出来る所までは出来てません。またもちろんcacheも出来てません。
誰かやってください。
Posted at by



2010/04/01


rubyのmongrelやthinなんかに変わるhttpdでUnicornとやらがあるのを知った。
ひとまずベンチ取ってみた。rubyでやる専用なのでなにかアプリを書かないと動かないのかな?とりあえずsinatraアプリ書いた。

unicorn-test.rb
require 'rubygems'
require 'sinatra'
set :public, File.dirname(__FILE__)
config.ru
require 'unicorn-test'
run Sinatra::Application
で、unicorn実行。ベンチは
# ab -n 1000 -c 10 -k http://localhost:8080/helloworld.html 2>&1 | tee unicorn.log
で確認した。

unicornの結果

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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /helloworld.html
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   5.385 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      193386 bytes
HTML transferred:       11022 bytes
Requests per second:    185.69 [#/sec] (mean)
Time per request:       53.855 [ms] (mean)
Time per request:       5.385 [ms] (mean, across all concurrent requests)
Transfer rate:          35.07 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    12   53  43.2     33     260
Waiting:       11   53  43.1     32     260
Total:         12   54  43.1     33     260

Percentage of the requests served within a certain time (ms)
  50%     33
  66%     42
  75%     56
  80%    106
  90%    119
  95%    140
  98%    176
  99%    212
 100%    260 (longest request)
一応、prefork付きのapache2でも...
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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.2.12
Server Hostname:        localhost
Server Port:            80

Document Path:          /helloworld.html
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   0.341 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    996
Total transferred:      322825 bytes
HTML transferred:       11000 bytes
Requests per second:    2931.25 [#/sec] (mean)
Time per request:       3.412 [ms] (mean)
Time per request:       0.341 [ms] (mean, across all concurrent requests)
Transfer rate:          924.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     0    3   7.8      0      40
Waiting:        0    3   7.8      0      40
Total:          0    3   7.8      0      40

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%     18
  95%     21
  98%     32
  99%     35
 100%     40 (longest request)
いちおうのいちおうでtthttpd(tinytinyhttpd)でも
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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8081

Document Path:          /helloworld.html
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   0.431 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    1000
Total transferred:      183000 bytes
HTML transferred:       11000 bytes
Requests per second:    2321.65 [#/sec] (mean)
Time per request:       4.307 [ms] (mean)
Time per request:       0.431 [ms] (mean, across all concurrent requests)
Transfer rate:          414.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     0    4  15.1      0     241
Waiting:        0    4  15.0      0     241
Total:          0    4  15.1      0     241

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      7
  95%     29
  98%     44
  99%     54
 100%    241 (longest request)

結論: preforkつえー。


えっ?そういう調査でしたっけ...
Posted at by