Skip to content
A high-performance and easy-to-use HTTP service framework.
Branch: master
Clone or download
Latest commit 1da0739 Mar 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cgi-handler
examples
.gitignore
BasicAuth.h
Buffer.h
CMakeLists.txt
CgiHelper.h
CgiWrapper.cpp
CgiWrapper.h
CheckPoint.h
CheckPointInject.cpp
ConfHelper.cpp
ConfHelper.h
ConnIf.h
CryptoUtil.h
Dispatcher.cpp
Dispatcher.h
EQueue.h
Executor.cpp
Executor.h
HttpExecutor.cpp
HttpExecutor.h
HttpHandler.h
HttpParser.h
HttpProto.cpp
HttpProto.h
HttpReqInstance.h
HttpServer.cpp
HttpServer.h
KVVec.h
LICENSE
Log.cpp
Log.h
ManagePage.cpp
README.md
ServiceIf.h
SlibLoader.h
SslSetup.cpp
SslSetup.h
Status.cpp
Status.h
StrUtil.h
TcpConnAsync.cpp
TcpConnAsync.h
ThreadPool.cpp
ThreadPool.h
Timer.cpp
Timer.h
siege.png
status.png
tzhttpd.conf

README.md

tzhttpd

This is a high-performance while easy-to-be-used HTTP service framework, which can help you develop a HTTP-featured server easily and quickly.

Key Points of tzhttpd

  1. Developed with Boost.Asio, which means high-concurrency and high-performance. My little very poor virtual machine (1C1G) can support up to 1.5K QPS, so I believe it can satisfy performance requirement for most cases in production.
  2. Just supporting HTTP basic GET/POST methods, but can feed the need of most backend application gateway development. Parameters and post body are well handled and structed. Routing handlers based on uri regex-match, easy for configuration.
  3. Connection can be keep-alived, long-connection means higher performance, and can get ride of TIME-WAIT disasters, and the server also can be tuned to be automatically timed out and removed.
  4. Support loading handlers through .so library, this feature simulates legacy CGI deployment conveniently. This library try its best loading and updating handler with less impact for others. And much more amazing thing is that you can just build one tzhttpd instance and copy it everywhere, and write your handlers, build them to individual so file, add them to configure files and update configuration dynamically, just like plugins.
  5. Based on Boost library and C++0x standard, so can used in legacy but widely-deploied RHEL-6.x environment, also RHEL-7.x is officially supported.
  6. Support regex-based Http Basic Authorization.
  7. Not buggy, and has stood tests in a way in production environment.

Possible use case

  1. General Web server, KIDDING. tzhttpd does not support full HTTP protocal, so it may not behave well in this situation. But I also add the VHost, Cache Control and some other features, and my homepage is hosted by this, it works fine currently.
  2. Backend application gateway, YES. tzhttpd is designed and optimized for this purpose.
  3. HTTP protocal adaptor. This way tzhttpd can be use as proxy, it can accept and parse HTTP request, forward the request and transform corresponding respose as standard HTTP response.
  4. Service manage interface. You can integrate tzhttpd into your already project, then you can send customize uri to interfere your service, such as configuration update, runtime statistic output, ... Actually I am changing most of my projects using HTTP interface, before these were implemented by kill Signal.

Performance

siege

Internal UI

# system status
curl 'http://127.0.0.1:18430/internal/status'

# dynamic update runtime conf
curl 'http://127.0.0.1:18430/internal/updateconf'

# reload so handler
curl 'http://127.0.0.1:18430/internal/drop?uri=^/cgi-bin/getdemo.cgi$'
curl 'http://127.0.0.1:18430/internal/status'
cp libgetdemo.so ../cgi-bin
curl 'http://127.0.0.1:18430/internal/updateconf'

The example status page looks like:
status

Attention:

With rdynamic and whole-archive link options, dynamic cgi-handler (through .so) can also use main program symbols, but those symbols should be built with --fvisibility=default, or your program in so may complain for undefined symbol. Though so deploy is convenient, but should be using very carefully, please use nm -r to check all U symbols of your *.so, and use readelf -s to check whether these symbol are DEFAULT visibility in the main program.

Reference project

tzmonitor http_face example.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.