Rental books
- to study about major player in the market. If you know better about it, you can get something worth from. Bankers is the bast player to study, because it study hard, and obey its role-model hard. (Innovative Bankers are exception.) Predictable-player will lose in the market sometime. (of course, the most predictable player is the Goverment and its sponsers = we citizen :-p
- 作者: J・E・スティグリッツ,ブルースグリーンウォルド,ジョセフ・E.スティグリッツ,Joseph E. Stiglitz
- 出版社/メーカー: 東京大学出版会
- 発売日: 2003/10/31
- メディア: 単行本
- 購入: 9人 クリック: 50回
- この商品を含むブログ (20件) を見る
- 作者: 大堀淳
- 出版社/メーカー: 共立出版
- 発売日: 1997/02
- メディア: 単行本
- クリック: 55回
- この商品を含むブログ (15件) を見る
- 作者: 田中一之
- 出版社/メーカー: 東京大学出版会
- 発売日: 2007/03
- メディア: 単行本
- 購入: 5人 クリック: 6回
- この商品を含むブログ (14件) を見る
コンピュータ・アーキテクチャ―設計・実現・評価の定量的アプローチ
- 作者: デイビッド・A.パターソン,ジョン・L.ヘネシー,David A. Patterson,John L. Hennessy,富田真治,新実治男,村上和彰
- 出版社/メーカー: 日経BP社
- 発売日: 1994/02
- メディア: 単行本
- 購入: 2人 クリック: 25回
- この商品を含むブログ (14件) を見る
適応型webサーバ
レスポンスが遅いか、忙しいモジュールは、インスタンスが増えるかキャッシュされる。
アクセスのツリー単位でキャッシュする。
データは要らないけどFYI、というリクエストの拡張。
<追記:2008/6/27>
acceptする場合、リクエストだけを受け付けてmemcachedとかにpoolしておき、適宜取り出して応答する。
レスポンスはすげー遅いが、hashならば同じアクセスを一度にさばけるかも
以下超てきとうなcode
start_childpool(H|) -> spawn (fun() -> child() end).
start_childpppl(H|T) -> spawn (fun() -> child() end),
start_childpool(T).
svr() ->
receive
{Request} -> if ( H = hit_hash(get_uri(Request))
append_request_to_hash(H, Request)
else
put_hash(Request,)
end,
svr().
end
child()
return_fetch_request
just compilable :-< code below.
-module(requestquehttpd).
-compile(export_all).
-define(IDLEWAIT, 100).
-define(NUMCHILDREN,10).
start_all() ->
RequestPool= ets:new(requestpool, [set, public]),
ContentsCache = ets:new(contentscache, [set, public]),
start_responderpool(?NUMCHILDREN, RequestPool,ContentsCache),
{ok, Listen} = gen_tcp:listen(8080, [binary, {packet,0},
{reuseaddr, true},
{active, true}]),
accept_loop(Listen, RequestPool).
accept_loop(Listen, RequestPool) ->
{ok, Socket} = gen_tcp:accept(Listen),
spawn(fun() -> justsave_request(RequestPool, Socket, ) end),
accept_loop(Listen, RequestPool).
justsave_request(RequestPool, Socket, T) ->
receive
{tcp, Socket, Bin} ->
justsave_request(RequestPool, Socket, T ++ Bin);
{tcp_closed, Socket} ->
ets:insert(RequestPool, {T, Socket})
end.
start_responderpool (0, ReqCache, ContentsCache) ->
spawn (fun() -> child(ReqCache, ContentsCache) end);
start_responderpool (N, ReqCache, ContentsCache) ->
spawn (fun() -> child(ReqCache, ContentsCache) end),
start_responderpool(N - 1, ReqCache, ContentsCache).
child(ReqCache, ContentsCache) ->
HIT = ets:lookup(ReqCache, ets:first(ReqCache)),
case HIT of
[{Request, Socket, }] ->
send_content(Socket, get_content(Request, ContentsCache));
[{_Request, Socket, Content}] ->
send_content(Socket, Content);
_ -> receive
after ?IDLEWAIT ->
do_nothing
end,
child(ReqCache, ContentsCache)
end.
get_content(_stub_R, _stub_C) ->
stub_code.
send_content(_stub_Socket, _stub_Data) ->
stub_code.
To make adabptable, I/F to
- add/remove worker process
- define variation (Template) of worker process (attach call-back function to each process)
For real use,
- garbage (zombie connection) collection mechanism
- timeout of cache
Anyway, it will be fun to testing.
</追記:2008/6/27>