Code Monkey home page Code Monkey logo

pangpang's Introduction

pangpang

High performance web server and application server for c++

wiki

wiki

Benchmark

pangpang-0.8.8, 2 process VS nginx-1.13.7,2 workprocess

static file: nginx index.html

ab

ab -k

wrk

siege

webbench

webbench failed

hello,world

cpp servlet class

#include "servlet.hpp"
namespace hi{
class hello : public servlet {
    public:

        void handler(request& req, response& res) {
            res.headers.find("Content-Type")->second = "text/plain;charset=UTF-8";
            res.content = "hello,world";
            res.status = 200;
        }

    };
}

extern "C" hi::servlet* create() {
    return new hi::hello();
}

extern "C" void destroy(hi::servlet* p) {
    delete p;
}

cpp compile

g++ -std=c++11 -I/usr/local/pangpang/include  -shared -fPIC hello.cpp -o hello.so
install hello.so /usr/local/pangpang/mod

Dependency

  • linux
  • gcc,g++(c++11)
  • hiredis-devel
  • libevent-devel(require 2.1.8+ libevent)

centos

sudo yum install gcc gcc-c++ make pcre-devel zlib-devel openssl-devel hiredis-devel

ubuntu

sudo apt-get install build-essential libpcre3-dev zlib1g-dev libssl-dev libhiredis-dev 

Installation

make and sudo make install and sudo systemctl daemon-reload . prefix=/usr/local/pangpang.

Configure

see conf/pangpang.json

Run

sudo systemctl enable pangpang

sudo systemctl (start|stop|restart|status) pangpang

Configure example

see conf/pangpang.json and conf/pattern.conf

Base configure

{
    "daemon": true,
    "multiprocess": {
        "enable": true,
        "cpu_affinity": true,
        "size": 2
    },
    "host": "127.0.0.1",
    "port": 9000,
    "ssl": {
        "enable": false,
        "cert": "",
        "key": ""
    },
    "max_headers_size": 8192,
    "max_body_size": 1048567,
    "timeout": 60,
    "gzip": {
        "enable": true,
        "min_size": 51200,
        "max_size": 307200,
        "level": -1
    },
    "session": {
        "enable": true,
        "host": "127.0.0.1",
        "port": 6379,
        "expires": 600
    },
    "log": true,
    "temp_directory": "temp",
    "route": [{

            "pattern": "hello",
            "max_match_size": 0,
            "module": "mod/hello.so",
            "cache": {
                "enable": false,
                "expires": 300,
                "size": 30
            },
            "session": false,
            "header": false,
            "cookie": false,
            "gzip": false,
            "log": false
        },
        {

            "pattern": "form",
            "max_match_size": 30,
            "module": "mod/form.so",
            "cache": {
                "enable": false,
                "expires": 300,
                "size": 30
            },
            "session": false,
            "header": true,
            "cookie": true,
            "gzip": false,
            "log": false
        },
        {

            "pattern": "session",
            "max_match_size": 0,
            "module": "mod/session.so",
            "cache": {
                "enable": false,
                "expires": 300,
                "size": 30
            },
            "session": true,
            "header": false,
            "cookie": true,
            "gzip": false,
            "log": true
        }
    ],
    "static_server": {
        "enable": true,
        "root": "html",
        "default_content_type": "text/html",
        "list_directory": true,
        "mime": [{
                "extension": "html",
                "content_type": "text/html"
            }, {
                "extension": "txt",
                "content_type": "text/plain"
            }, {
                "extension": "js",
                "content_type": "application/x-javascript"
            },
            {
                "extension": "css",
                "content_type": "text/css"
            },
            {
                "extension": "jpg",
                "content_type": "image/jpeg"
            },
            {
                "extension": "jpeg",
                "content_type": "image/jpeg"
            },
            {
                "extension": "gif",
                "content_type": "image/gif"
            },
            {
                "extension": "png",
                "content_type": "image/png"
            },
            {
                "extension": "ico",
                "content_type": "image/x-icon"
            },
            {
                "extension": "json",
                "content_type": "application/json"
            },
            {
                "extension": "zip",
                "content_type": "application/zip"
            },
            {
                "extension": "*",
                "content_type": "application/octet-stream"
            }
        ]
    }
}

Route pattern configure

hello       =       ^/hello/?([0-9a-z]?)?$
form        =       ^/form/?([0-9a-z]+)?$
session     =       ^/session$

pangpang's People

Contributors

webcpp avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.