Hateburo: kazeburo hatenablog

SRE / 運用系小姑 / Goを書くPerl Monger

Entries from 2013-01-01 to 1 year

Starlet / How to listen to Unix Domain Socket without Server::Starter

Define $ENV{SERVER_STARTER_PORT} in your script. if (-S $socket) { warn "removing existing socket file:$socket"; unlink $socket or die "failed to remove existing socket file:$socket:$!"; } unlink $socket; my $sock = IO::Socket::UNIX->new( …

Amon2でKossy::Request/Responseを使う

使う事があるかどうかは置いといて、使えた package MyApp::Web; .. # request/response use Kossy::Request; use Kossy::Response; sub create_request { Kossy::Request->new($_[1]) } sub create_response { shift; Kossy::Response->new(@_) } メリット…

データベースのmasterとslaveの使い分けの話。2014年版

社内で少し話題になったので。運用上の話はfujiwaraさんのMySQLをmaster:slave=1:1構成にして参照をslaveに向けるのがなぜ良くないか - 酒日記 はてな支店 MySQLで参照の負荷分散を行うslaveは3台から構成するのがよいのでは - 酒日記 はてな支店をみてくだ…

Starlet + Server::Stater で UNIX domain socketに対応しました

Starlet-0.21がリリースされました。Starlet-0.21 - a simple, high-performance PSGI/Plack HTTP server - metacpan.org - Perl programming languageこのバージョンからServer::Staterとの組み合わせでUNIX domain socketをListenすることができるようにな…

ISUCON3 予選のAMIでスコア 65000点以上を出す方法 #isucon

ISUCON3 の予選AMIが公開されてから、ごにょごにょとHackした結果、スコアで65000まで出す事ができました。(一回だけ66000でけどたぶんインスタンスガチャ)「ISUCON 本戦出場者決定のお知らせ」をみると予選の時のトップのスコアが3.3万(自分たちは1.5万ぐら…

How to automate CPAN.pm configuration on Travis

I want to automate CPAN.pm configuration on Travis. I wrote .travis.yaml like this language: perl before_install: - cpanm -n CPAN - (echo y;echo y;echo o conf commit)|cpan - cpanm -n Module::Install Module::Install::Repository Module::Inst…

Kossy-0.24 Trial has been released. It contains new BodyParser

I released Kossy-0.24-Trial. It contains new request-body parser Kossy::BodyParser.https://metacpan.org/release/KAZEBURO/Kossy-0.24-TRIALKossy::BodyParser is based on tokuhirom's Plack::BodyParser https://github.com/plack/Plack/pull/434I t…

アプリケーションに手を入れずに #isucon 2013 予選のperlアプリケーションのスコアをあげてみようの巻

セッション管理モジュールやルーティングライブラリが速くなる事で何もしなくても isucon3 予選のperlのアプリケーションが高速化していく— masahiro nagano (@kazeburo) October 10, 2013ということで、やってみた。 初期 「オンライン予選で使用した問題が…

Monoceros-0.26 and Plack::Middleware::Static::OpenFileCache

Monoceros-0.26 uses sendfile(2) for sending file if Sys::Sendfile is available.https://metacpan.org/release/MonocerosPlack::Middleware::Static::OpenFileCache can cache opened file handles like nginx's open_file_cache. Static::OpenFileCache…

Plack::Middleware::Session::Simple has been released

English document is available on metacpan! Plack::Middleware::Session::Simpleをリリースしました。Plack::Middleware::Session(Store::Cache & State::Cookie)と互換性を保ちながら、効率よく動作することを狙っています。 必要なときに必要なだけ Set-…

Kossy::Validator

I released Kossy::Validator to CPAN. It was separated from Kossyhttps://metacpan.org/release/Kossy-ValidatorYou can use Kossy::Validator modules w/o Kossy.ぜひ毎日通って下さいww RT @mackee_w: Kossy::Validator分離してくだされ〜〜〜〜〜〜〜…

Cache::Memcached::Fast::Safe 0.04 was out. It has get_or_set()

I added get_or_set() to Cache::Memcached::Fast::Safe and released as ver. 0.04https://metacpan.org/release/Cache-Memcached-Fast-SafeI saw some people make a module that inherits Cache::Memcached::Fast::Safe only for adding get_or_set(). sa…

Released Kossy-0.23. Improve Performance

Kossy-0.23 gets 2x or more faster. https://metacpan.org/release/KossyI made these changes. Cache Kossy::Request->base. URI->canonical is slow. Use Router::Boom for router Use HTTP::Headers::Fast Optimize Kossy::Response->finalize Benchmark…

Plack::Middleware::Session uses Cookie::Baker

Plack::Middleware::Session 0.21 uses Cookie::Baker for improve performance. Cookie::Baker is simple cookie generator/parser module. https://metacpan.org/release/Plack-Middleware-SessionPrevious version of Plack::Middleware::Session uses Pl…

Released Cookie::Baker to CPAN

I released Cookie::Baker that provides HTTP cookie generator and parserhttp://search.cpan.org/~kazeburo/Cookie-Baker/ https://metacpan.org/release/Cookie-Baker### synopsis use Cookie::Baker; $headers->push_header('Set-Cookie', bake_cookie(…

Monoceros supports accept4(2)

tokuhirom released Linux::Socket::Accept4 that provides accept4(2) Monoceros-0.25 uses accept4 if Linux::Socket::Accept4 is avaliable.accept4(2) can set FD_CLOEXEC and O_NONBLOCK in one system call.Monoceros-0.24 select(16, [4 10], NULL, N…

ISUCON3 予選に参加してきました。無念ばかり残る

isucon3予選に @sugyan @tagomorisとLINE選抜チームを組んで参加しました。共催枠なので結果に関わらず本戦には出れるのですが、結果は総合8位。無念です やったこと sugyanのエントリが詳しいのですが、自分がやったのは nginx(openresty)への入れ替え mysq…

The number of item that memcached-1.4.15 can keep is less than older version?

I decided to downgrade memcached because there was trouble several times in 1.4.15. After downgrading to 1.4.14, the memcached keeps item 7% more than 1.4.15.1.4.15 has a bug around slab allocator? ref: https://code.google.com/p/memcached/…

Nginx gzip and Vary. How to

I want to output "Vary: Accept-Encoding,User-Agent". But gzip_vary only adds Accept-Encoding. "add_header Vary" does not merge headers.My answer is.. location / { gzip on; gzip_disable "MSIE [1-6]\."; gzip_types text/css application/x-java…

xbuildとCartonを利用したPerlアプリケーションのデプロイ環境の構築

最近、新しいサーバでサービスを動かしたりベンチマークを取る場合には、モリスさんのxbuildを使ってるhttps://github.com/tagomoris/xbuildxbuildを使うとローカルの任意のディレクトリにPerl(Ruby,Node.js,PHP,Pythonにも対応)のランタイムを設置してくれ…

Released Plack::Middleware::ServerStatus::Lite 0.30, includes server-status command

I released Plack::Middleware::ServerStatus::Lite 0.30. This version includes `server-status` command.https://metacpan.org/release/Plack-Middleware-ServerStatus-Liteserver-status command is able to display server status without HTTP request…

Released Cache::Memcached::Fast::Safe 0.03, fixed connection leak bug

I released Cache::Memcached::Fast::Safe 0.03 to cpanhttps://metacpan.org/module/Cache::Memcached::Fast::Safeversion 0.02 has a connection leaking bug. Please update if you use this.

Starlet and Monoceros reached 100kreqs/sec

Preforking Plack::Handler, Starlet and Monoceros reached 100kreq/sec on my "Hello World" benchmark. Starlet $ plackup -s Starlet -E produnction --max-workers 40 --max-reqs-per-child 50000 \ -max-keepalive-reqs 10000 -e 'sub{[200,[],["Hello…

Plack < 1.0029 and http_proxy

Plack $ no_proxy=www.cpan.org http_proxy=http://localhost:3941 cpanm --test-only MIYAGAWA/Plack-1.0028.tar.gz --> Working on MIYAGAWA/Plack-1.0028.tar.gz Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/Plack-1.0028.tar.gz ... OK Conf…

Starlet 0.20 supports HTTP/1.1 / Benchmark by wrk

PSGI/Plack HTTP server Starlet 0.20 that was released last week, supports HTTP/1.1.https://metacpan.org/release/Starlet https://github.com/kazuho/StarletPrevious versions of Starlet only support HTTP/1.0 and HTTP/1.0 keepalive, but finally…

MacBookAir 買ったらスグ入れたい!エンジニア必携ツール1個

Secrets

Cache::Memcached::Fast::Safe - preventing memcached injection

Cache::Memcached::Fast::Safe is subclass of Cache::Memcached::Fast. Cache::Memcached::Fast::Safe sanitizes all requested keys for against memcached injection problem. and call disconnect_all automatically after fork for fork-safe.https://m…

Proclet supports $PORT auto assignment in Proclet-0.30

proclet command (foreman for perl) that included in Proclet distribution, now supports auto assignment of $PORT that written in Procfile.https://metacpan.org/release/ProcletIn Procfile web: plackup -p $PORT -a app.psgi admin: plackup -p $P…

Server::Starter 0.13 was released. It supports `start_server --dir /path/to`

In Server::Starter 0.13, --dir option was added to start_server. start_server will do chdir to a specified directory before exec(2). It's useful when you use carton, proclet and deploy tool like capistrano that does rsync all project files…

Furlでサーバへの接続に掛かった時間とレスポンスに掛かった時間を取得する方法

AnyEvent::HTTPの続き package MyFurl::HTTP; use strict; use warnings; use base qw/Furl::HTTP/; use Time::HiRes; sub response_time { if ( @_ > 1 ) { $_[0]->{times} = $_[1]; } $_[0]->{times}; } sub connect : method { my($self, $host, $port, $…