-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparams.json
1 lines (1 loc) · 14.4 KB
/
params.json
1
{"name":"Trusterd - HTTP/2 Web Server scripting with mruby","tagline":"","body":"![logo](https://raw.githubusercontent.com/trusterd/trusterd/master/images/logo_full_white.png)\r\n\r\n> Special thanks to @maybehelpy for creating trusterd logo!!\r\n\r\n# Trusterd HTTP/2 Web Server\r\n\r\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/trusterd/trusterd?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\r\n[![Build Status](https://travis-ci.org/trusterd/trusterd.svg?branch=master)](https://travis-ci.org/trusterd/trusterd)\r\n[![wercker status](https://app.wercker.com/status/d389a8a05b263e469d51f40d532af04f/s \"wercker status\")](https://app.wercker.com/project/bykey/d389a8a05b263e469d51f40d532af04f)\r\n\r\n[Trusterd](https://github.com/trusterd/trusterd) is a high performance HTTP/2 Web Server scripting with [mruby](https://github.com/mruby/mruby) using [nghttp2](https://github.com/tatsuhiro-t/nghttp2) and [mruby-http2](https://github.com/trusterd/mruby-http2). You can get HTTP/2 Web Server quickly which is high permance and customizable with mruby. The HTTP/2 server and client function are pluggable. So, [you can embed these functions into your C applications](https://github.com/trusterd/trusterd/blob/master/README.md#embed-into-your-c-application).\r\n\r\n## TODO\r\nThis is a very early version, please test and report errors. Wellcome pull-request.\r\n- Server Push\r\n\r\n## Requirements\r\n\r\n- [nghttp2 Requirements](https://github.com/tatsuhiro-t/nghttp2#requirements)\r\n- [mruby-http2 Requirements](https://github.com/trusterd/mruby-http2/blob/master/mrbgem.rake#L6)\r\n- Trusterd Requirements\r\n - libjemalloc-dev\r\n - [qrintf-gcc](https://github.com/h2o/qrintf)\r\n - If you don't have jemalloc and qrintf-gcc, comment out these lines on [build_config.rb](https://github.com/trusterd/trusterd/blob/master/build_config.rb#L34-L62)\r\n- If you use prefork mode, linux kernel need to support `SO_REUSEPORT`.\r\n\r\nAfter reading [.travis.yml](https://github.com/trusterd/trusterd/blob/master/.travis.yml), you might easy to understand the install\r\n\r\n## Quick install\r\n### Manual Build\r\n#### 1. Install qrintf (Optional, but recommended)\r\nPlease see [qrintf-gcc](https://github.com/h2o/qrintf)\r\n\r\nor commet out this line in `build_config.rb`\r\n\r\n```\r\ncc.command = ENV['CC'] || 'qrintf-gcc'\r\n```\r\n\r\n#### 2. Install jemalloc (Optional, but recommended)\r\n##### Ubuntu\r\n```\r\nsudo apt-get install libjemalloc-dev\r\n```\r\n\r\nor comment out this line in `build_config.rb`\r\n\r\n```\r\nlinker.flags_after_libraries << '-ljemalloc'\r\n```\r\n\r\n#### 3. Download trusterd\r\n```\r\ngit clone https://github.com/trusterd/trusterd.git\r\ncd trusterd\r\n```\r\n#### 4. Build trusterd\r\n```bash\r\nmake\r\n```\r\n#### 5. Install\r\n```bash\r\nmake install INSTALL_PREFIX=/usr/local/trusterd\r\n```\r\n#### 6. Write config ``$(INSTALL_PREFIX)/conf/trusterd.conf.rb``\r\n```ruby\r\nSERVER_NAME = \"Trusterd\"\r\nSERVER_VERSION = \"0.0.1\"\r\nSERVER_DESCRIPTION = \"#{SERVER_NAME}/#{SERVER_VERSION}\"\r\n\r\nroot_dir = \"/usr/local/trusterd\"\r\n\r\ns = HTTP2::Server.new({\r\n\r\n #\r\n # required config\r\n #\r\n\r\n :port => 8080,\r\n :document_root => \"#{root_dir}/htdocs\",\r\n :server_name => SERVER_DESCRIPTION,\r\n\r\n # support prefork only when linux kernel supports SO_REUSEPORT\r\n # :worker => 4,\r\n\r\n # detect cpu thread automatically\r\n # If don't support SO_REUSEPORT of Linux, the number of worker is 0\r\n :worker => \"auto\",\r\n\r\n # required when tls option is true.\r\n # tls option is true by default.\r\n #:key => \"#{root_dir}/ssl/server.key\",\r\n #:crt => \"#{root_dir}/ssl/server.crt\",\r\n #:dh_params_file => \"#{root_dir}/ssl/dh.pem\",\r\n\r\n # listen ip address\r\n # default value is 0.0.0.0\r\n # :server_host => \"127.0.0.1\",\r\n\r\n #\r\n # optional config\r\n #\r\n\r\n # debug default: false\r\n # :debug => true,\r\n\r\n # tls default: true\r\n :tls => false,\r\n\r\n # damone default: false\r\n # :daemon => true,\r\n\r\n # callback default: false\r\n # :callback => true,\r\n\r\n # connection_record defualt: true\r\n # :connection_record => false,\r\n\r\n # runngin user, start server with root and change to run_user\r\n # :run_user => \"daemon\",\r\n\r\n # Tuning RLIMIT_NOFILE, start server with root and must set run_user instead of root\r\n # :rlimit_nofile => 65535,\r\n\r\n # Set TCP_NOPUSH (TCP_CORK) option\r\n # :tcp_nopush => true,\r\n\r\n # expand buffer size before writing packet. decreace the number of small packets. That may be usefull for TLS session\r\n # :write_packet_buffer_expand_size => 4096 * 4,\r\n\r\n # limit buffer size before writing packet. write packet beyond the value. That may be usefull for TLS session\r\n # :write_packet_buffer_limit_size => 4096,\r\n\r\n # measuring server status: default false\r\n # :server_status => true,\r\n\r\n # use reverse proxy methods: default false\r\n # :upstream => true,\r\n\r\n})\r\n\r\n#\r\n# when :callback option is true,\r\n#\r\n# # custom request headers\r\n# # getter\r\n# s.r.headers_in[\":method\"] #=> GET\r\n# s.r.request_headers[\":method\"] #=> GET\r\n#\r\n# # custom response headers\r\n# # setter\r\n# s.r.headers_out[\"hoge\"] = fuga\r\n# s.r.response_headers[\"hoge\"] = fuga\r\n#\r\n# # getter\r\n# s.r.headers_out[\"hoge] #=> fuga\r\n# s.r.response_headers[\"hoge] #=> fuga\r\n#\r\n#\r\n# s.set_map_to_storage_cb {\r\n#\r\n# p \"callback bloack at set_map_to_storage_cb\"\r\n# p s.filename #=> /path/to/index.html\r\n# p s.uri #=> /index.html\r\n# p s.unparsed_uri #=> /index.html?a=1&b=2\r\n# p s.percent_encode_uri #=> /index.html?id=%E3%83%9F%E3\r\n# p s.args #=> ?a=1&b=2\r\n# p s.body #=> \"post data\"\r\n# p s.method #=> \"GET\"\r\n# p s.scheme #=> \"https\"\r\n# p s.authority #=> \"matsumoto-r.jp\"\r\n# p s.host #=> \"matsumoto-r.jp\"\r\n# p s.hostname #=> \"matsumoto-r.jp\"\r\n# p s.client_ip #=> \"192.168.12.5\"\r\n# p s.document_root #=> \"/path/to/htdocs\"\r\n# p s.user_agent #=> \"trusterd_client\"\r\n#\r\n# p \"if :server_status is true, use server status method\"\r\n# p \"the number of total requesting stream #{s.total_stream_request}\"\r\n# p \"the number of total requesting session #{s.total_session_request}\"\r\n# p \"the number of current connected sessions #{s.connected_sessions}\"\r\n# p \"the number of current processing streams #{s.active_stream}\"\r\n#\r\n# # location setting\r\n# if s.request.uri == \"/index.html\"\r\n# s.request.filename = \"#{root_dir}/htdocs/hoge\"\r\n# end\r\n# p s.request.filename\r\n#\r\n# # you can use regexp if you link regexp mrbgem.\r\n# # Or, you can use KVS like mruby-redis or mruby-\r\n# # vedis and so on.\r\n#\r\n# # reverse proxy config\r\n# # reciev front end with HTTP/2 and proxy upstream server with HTTP/1.x\r\n# # TODO: don't support connection with TLS to upstream server\r\n# #\r\n# # need :upstream => true\r\n#\r\n# if s.request.uri =~ /^/$/\r\n# # upstream request uri default: /\r\n# s.upstream_uri = s.percent_encode_uri\r\n# s.upstream_host = \"127.0.0.1\"\r\n#\r\n# # upstream port default: 80\r\n# #s.upstream_port = 8080\r\n#\r\n# # upstream connection timeout default: 600 sec\r\n# #s.upstream_timeout = 100\r\n#\r\n# # use keepalive deault: true\r\n# #s.upstream_keepalive = false\r\n#\r\n# # use HTTP/1.0 protocol default: HTTP/1.1\r\n# #s.upstream_proto_major = 1\r\n# #s.upstream_proto_minor = 0\r\n# end\r\n#\r\n# # dynamic content with mruby\r\n# if s.request.filename =~ /^.*\\.rb$/\r\n# s.enable_mruby\r\n# end\r\n#\r\n# # dynamic content with mruby sharing mrb_state\r\n# if s.request.filename =~ /^.*\\_shared.rb$/\r\n# s.enable_shared_mruby\r\n# end\r\n#\r\n# if s.request.uri =~ /hellocb/\r\n# s.set_content_cb {\r\n# s.rputs \"hello trusterd world from cb\"\r\n# s.echo \"+ hello trusterd world from cb with \\n\"\r\n# }\r\n# end\r\n#\r\n# }\r\n\r\n# extend response just before send response\r\n# s.set_fixups_cb {\r\n# s.r.response_headers[\"server\"] = \"other server\"\r\n#}\r\n\r\n# #If define set_content_cb this scope, callback only once\r\n# s.set_content_cb {\r\n# s.rputs \"hello trusterd world from cb\"\r\n# s.echo \"+ hello trusterd world from cb with \\n\"\r\n# }\r\n\r\n#\r\n# f = File.open \"#{root_dir}/logs/access.log\", \"a\"\r\n#\r\n# s.set_logging_cb {\r\n#\r\n# p \"callback block after send response\"\r\n#\r\n# f.write \"client_ip:'#{s.conn.client_ip}' date:'#{s.r.date}' status:#{s.r.status} content_length:#{s.r.content_length} uri:'#{s.r.uri}' filename:'#{s.r.filename}' user_agent:'#{s.r.user_agent}'\\n\"\r\n#\r\n# }\r\n\r\n#\r\n# or use access logging methods\r\n#s.setup_access_log({\r\n# :file => \"/usr/local/trusterd/logs/access.log\",\r\n#\r\n# # :default or :custom\r\n# # if using :custom, set logging format to write_access_log mehtod arg\r\n# # s.write_access_log \"client_ip: #{s.client_ip}\"\r\n# :format => :default,\r\n#\r\n# # :plain or :json if using :default\r\n# :type => :plain,\r\n#})\r\n#\r\n#s.set_logging_cb {\r\n# s.write_access_log\r\n#}\r\n#\r\n\r\n\r\ns.run\r\n```\r\n#### 7. Run trusterd\r\n```bash\r\nmake start INSTALL_PREFIX=/usr/local/trusterd\r\n```\r\n\r\nor\r\n\r\n```bash\r\n$(INSTALL_PREFIX)/bin/trusterd $(INSTALL_PREFIX)/conf/trusterd.conf.rb\r\n```\r\n\r\n#### 8. Check by nghttp\r\n[nghttp](https://github.com/tatsuhiro-t/nghttp2#nghttp---client) is a client tool for HTTP/2.\r\n```\r\n$ ${GIT_CLONE_DIR}/mruby/build/host/mrbgems/mruby-http2/nghttp2/src/nghttp -v http://127.0.0.1:8080/index.html\r\nhello trusterd world.\r\n```\r\n\r\n#### Clean\r\n```\r\nmake clean\r\n```\r\n----\r\n\r\n### Using Docker\r\n#### Using Docker image\r\n##### Pulling\r\n```\r\ndocker pull matsumotory/trusterd\r\n```\r\n##### Running\r\n```\r\ndocker run -d -p 8080:8080 matsumotory/trusterd\r\n```\r\n##### Access\r\n```\r\nnghttp -v http://127.0.0.1:8080/index.html\r\n```\r\n#### Docker Image Build\r\n##### Building\r\n```\r\ndocker build -t local/trusterd .\r\n```\r\n##### Runing\r\nYou can run trusted directly.\r\n```\r\n$ docker run --rm local/trusterd --help\r\nUsage: ./bin/trusterd [switches] programfile\r\n switches:\r\n -b load and execute RiteBinary (mrb) file\r\n -c check syntax only\r\n -e 'command' one line of script\r\n -v print version number, then run in verbose mode\r\n --verbose run in verbose mode\r\n --version print the version\r\n --copyright print the copyright\r\n```\r\nRun with default configration. ([docker/conf/trusterd.conf.rb](./docker/conf/trusterd.conf.rb))\r\n```\r\ndocker run -d -p 8080:8080 local/trusterd\r\n```\r\nRun with your configration.\r\n```\r\nmkdir localconf\r\nvi localconf/your_config.rb ## Write your configration.\r\n$ docker run -d -v `pwd`/localconf:/usr/local/trusterd/localconf -p 8080:8080 local/trusterd ./localconf/your_config.rb\r\n```\r\n\r\n##### Access\r\n```\r\nnghttp -v http://127.0.0.1:8080/index.html\r\n```\r\n\r\n## Embed into your C application\r\n### HTTP/2 Server fucntion\r\nSee [src/mini_trusterd.c](https://github.com/trusterd/trusterd/blob/master/src/mini_trusterd.c)\r\n\r\n### HTTP/2 Client function\r\nSee [src/mini_trusterd_client.c](https://github.com/trusterd/trusterd/blob/master/src/mini_trusterd_client.c)\r\n\r\n## Peformance\r\n### Machine\r\n\r\n- Ubuntu14.04 on VMWare\r\n- Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz 4core\r\n- Memory 8GB\r\n\r\n### Config\r\n#### trusterd.conf.rb\r\n```ruby\r\nSERVER_NAME = \"Trusterd\"\r\nSERVER_VERSION = \"0.0.1\"\r\nSERVER_DESCRIPTION = \"#{SERVER_NAME}/#{SERVER_VERSION}\"\r\n\r\nroot_dir = \"/usr/local/trusterd\"\r\n\r\ns = HTTP2::Server.new({\r\n\r\n :port => 8081,\r\n :document_root => \"#{root_dir}/htdocs\",\r\n :server_name => SERVER_DESCRIPTION,\r\n :tls => false,\r\n\r\n})\r\n\r\ns.run\r\n```\r\n\r\n### Benchmarks\r\n\r\n[h2load](https://github.com/tatsuhiro-t/nghttp2#benchmarking-tool) is a benchmark tool for HTTP/2.\r\n\r\n- use [h2o/h2o benchmark parameter](https://github.com/h2o/h2o#benchmarks)\r\n\r\n#### 4 worker mode benchmark demo\r\n500,000 reqeuat/sec is very fater!!\r\n![](https://raw.githubusercontent.com/trusterd/trusterd/master/images/bench.png)\r\n\r\n#### 4 worker mode cpu usage by top demo\r\ntrusterd worker processes use cpu resources of full core mostly.\r\n![](https://raw.githubusercontent.com/trusterd/trusterd/master/images/top.png)\r\n\r\n#### HTTP/2\r\n\r\n|Server \\ size of content|6 bytes|4,096 bytes|\r\n|------------------------|------:|----------:|\r\n|nghttpd ([nghttpd @ a08ce38](https://github.com/tatsuhiro-t/nghttp2/)) single thread|148,841|73,812|\r\n|nghttpd ([nghttpd @ a08ce38](https://github.com/tatsuhiro-t/nghttp2/)) multi thread|347,152|104,244|\r\n|tiny-nghttpd ([nghttpd @ a08ce38](https://github.com/tatsuhiro-t/nghttp2/)) single thread|190,223|82,047|\r\n|[Trusterd @ 2432cc5](https://github.com/trusterd/trusterd) single process|204,769|92,068|\r\n|[Trusterd @ 2432cc5](https://github.com/trusterd/trusterd) multi process|509,059| 134,542 |\r\n|[H2O @ 529be4e](https://github.com/h2o/h2o) single thread |216,453| 112,356|\r\n|[H2O @ 529be4e](https://github.com/h2o/h2o) multi thread |379,623| 146,343|\r\n\r\n`h2load -c 500 -m 100 -n 2000000`\r\n\r\n\r\n#### Ref: HTTP/1.1 on same benchmark environment\r\n\r\n|Server \\ size of content|6 bytes|4,096 bytes|\r\n|------------------------|------:|----------:|\r\n|nginx single process|21,708| 22,366 |\r\n|nginx multi process|67,349| 56,203 |\r\n\r\n`weighttp -k -c 500 -n 200000`\r\n\r\n\r\n## Memory\r\n#### Startup\r\n```\r\nUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\r\nroot 62085 0.0 0.0 46668 2288 pts/4 S+ 16:41 0:00 | \\_ /usr/local/trusterd/bin/trusterd /usr/local/trusterd/conf/trusterd.conf.rb\r\n```\r\n#### After processing ten million request\r\n```\r\nUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\r\nroot 62085 63.3 0.0 49200 5144 pts/4 S+ 16:41 0:47 | \\_ /usr/local/trusterd/bin/trusterd /usr/local/trusterd/conf/trusterd.conf.rb\r\n```\r\n## License\r\nunder the MIT License:\r\n\r\n* http://www.opensource.org/licenses/mit-license.php\r\n\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}