Browse Source

Update drogon to the latest version and reduce the number of DB connections (#4939)

An Tao 6 years ago
parent
commit
cf06cbd8be

+ 22 - 1
frameworks/C++/drogon/benchmark_config.json

@@ -45,7 +45,28 @@
         "display_name": "drogon",
         "display_name": "drogon",
         "notes": "",
         "notes": "",
         "versus": "None"
         "versus": "None"
+      },
+      "core": {
+        "db_url": "/db",
+        "fortune_url": "/fortunes",
+        "query_url": "/queries?queries=",
+        "update_url": "/updates?queries=",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Fullstack",
+        "database": "Postgres",
+        "framework": "drogon",
+        "language": "C++",
+        "flavor": "None",
+        "orm": "Raw",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "drogon",
+        "notes": "",
+        "versus": "None"
       }
       }
     }
     }
   ]
   ]
-}
+}

+ 45 - 0
frameworks/C++/drogon/drogon-core.dockerfile

@@ -0,0 +1,45 @@
+FROM ubuntu:18.04
+
+COPY ./ ./
+
+RUN  apt update -yqq && \
+     apt-get install -yqq software-properties-common && \
+	 apt install -yqq sudo curl wget cmake locales git \
+     openssl libssl-dev \
+     libjsoncpp-dev \
+     uuid-dev \
+     zlib1g-dev \
+	 postgresql-server-dev-all && \
+     add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
+	 apt update -yqq && \
+	 apt install -yqq gcc-8 g++-8
+
+RUN locale-gen en_US.UTF-8
+
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+ENV LC_ALL en_US.UTF-8
+
+ENV CC=gcc-8
+ENV CXX=g++-8
+ENV AR=gcc-ar-8
+ENV RANLIB=gcc-ranlib-8
+
+ENV IROOT=/install
+ENV DROGON_ROOT=$IROOT/drogon
+ENV TEST_PATH=/drogon_benchmark/build
+WORKDIR $IROOT
+
+RUN git clone https://github.com/an-tao/drogon
+
+WORKDIR $DROGON_ROOT
+
+RUN git checkout 135a2ebb6f63ee91ec1f11817b7bf68f1591ba43
+
+RUN ./build.sh
+
+WORKDIR $TEST_PATH
+
+RUN cmake ..
+RUN make
+CMD ./drogon_benchmark config-core.json

+ 1 - 1
frameworks/C++/drogon/drogon-raw.dockerfile

@@ -34,7 +34,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 
 WORKDIR $DROGON_ROOT
 WORKDIR $DROGON_ROOT
 
 
-RUN git checkout d56b71c8a9b2b4bd0dd67052fe87c4768adfeb66
+RUN git checkout 135a2ebb6f63ee91ec1f11817b7bf68f1591ba43
 
 
 RUN ./build.sh
 RUN ./build.sh
 
 

+ 1 - 1
frameworks/C++/drogon/drogon.dockerfile

@@ -34,7 +34,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 
 WORKDIR $DROGON_ROOT
 WORKDIR $DROGON_ROOT
 
 
-RUN git checkout d56b71c8a9b2b4bd0dd67052fe87c4768adfeb66
+RUN git checkout 135a2ebb6f63ee91ec1f11817b7bf68f1591ba43
 
 
 RUN ./build.sh
 RUN ./build.sh
 
 

+ 174 - 0
frameworks/C++/drogon/drogon_benchmark/config-core.json

@@ -0,0 +1,174 @@
+/* This is a JSON format configuration file
+ */
+{
+    //ssl:the global ssl files setting
+    /*
+    "ssl": {
+      "cert": "../../trantor/trantor/tests/server.pem",
+      "key": "../../trantor/trantor/tests/server.pem"
+    },*/
+    "listeners": [{
+        //address:ip address,0.0.0.0 by default
+        "address": "0.0.0.0",
+        //port:port number
+        "port": 8080,
+        //https:if use https for security,false by default
+        "https": false
+    }],
+    "db_clients": [{
+        //name:Name of the client,'default' by default
+        //"name":"",
+        //rdbms:server type, "postgreSQL" by default
+        "rdbms": "postgreSQL",
+        //host:server address,localhost by default
+        "host": "tfb-database",
+        //port:server port, 5432 by default
+        "port": 5432,
+        //dbname:Database name
+        "dbname": "hello_world",
+        //user:'postgres' by default
+        "user": "benchmarkdbuser",
+        //passwd:'' by default
+        "passwd": "benchmarkdbpass",
+        //is_fast: false by default, if it is true, the client is faster but user can't call
+        //any synchronous interface of it.
+        "is_fast": true,
+        //connection_number:1 by default
+        "connection_number": 1
+    }],
+    "app": {
+        //threads_num:the number of IO threads,1 by default, if the value is set to 0, the number of threads
+        //will be the number of processors.
+        "threads_num": 0,
+        //enable_session:false by default
+        "enable_session": false,
+        "session_timeout": 0,
+        //document_root:Root path of HTTP document,defaut path is ./
+        "document_root": "./",
+        /* file_types:
+         * HTTP download file types,The file types supported by drogon
+         * by default are "html", "js", "css", "xml", "xsl", "txt", "svg",
+         * "ttf", "otf", "woff2", "woff" , "eot", "png", "jpg", "jpeg",
+         * "gif", "bmp", "ico", "icns", etc. */
+        "file_types": [
+            "gif",
+            "png",
+            "jpg",
+            "js",
+            "css",
+            "html",
+            "ico",
+            "swf",
+            "xap",
+            "apk",
+            "cur",
+            "xml"
+        ],
+        //max_connections:max connections number,100000 by default
+        "max_connections": 100000,
+        //max_connections_per_ip:max connections number per clinet,0 by default which means no limit
+        "max_connections_per_ip": 0,
+        //Load_dynamic_views: false by default, when set to true, drogon will
+        //compile and load dynamically "CSP View Files" in directories defined
+        //by "dynamic_views_path"
+        //"load_dynamic_views":true,
+        //dynamic_views_path: if the path isn't prefixed with / or ./,
+        //it will be relative path of document_root path
+        //"dynamic_views_path":["./views"],
+        //log:set log output,drogon output logs to stdout by default
+        "log": {
+            //log_path:log file path,empty by default,in which case,log will output to the stdout
+            //"log_path": "./",
+            //logfile_base_name:log file base name,empty by default which means drogon will name logfile as
+            //drogon.log ...
+            "logfile_base_name": "",
+            //log_size_limit:100000000 bytes by default,
+            //When the log file size reaches "log_size_limit", the log file will be switched.
+            "log_size_limit": 100000000,
+            //log_level:"DEBUG" by default,options:"TRACE","DEBUG","INFO","WARN"
+            //The TRACE level is only valid when built in DEBUG mode.
+            "log_level": "WARN"
+        },
+        //run_as_daemon:false by default
+        "run_as_daemon": false,
+        //relaunch_on_error:false by default,if true,the program will be restart by parent after exit;
+        "relaunch_on_error": false,
+        //use_sendfile:true by default,if ture,the program will
+        //use sendfile() system-call to send static file to client;
+        "use_sendfile": true,
+        //use_gzip:true by default,use gzip to compress the response body's content;
+        "use_gzip": false,
+        //static_files_cache_time:5 (seconds) by default,the time in which static file response is cached,
+        //0 means cache forever,the negative value means no cache
+        "static_files_cache_time": 5,
+        //simple_controllers_map:Configuring mapping from path to simple controller
+        "simple_controllers_map": [
+            {
+                "path": "/db",
+                "controller": "DbCtrlRaw",
+                "http_methods": [
+                    "get"
+                ]
+            },
+            {
+                "path": "/fortunes",
+                "controller": "FortuneCtrlRaw",
+                "http_methods": [
+                    "get"
+                ]
+            },
+            {
+                "path": "/queries",
+                "controller": "QueriesCtrlRaw",
+                "http_methods": [
+                    "get"
+                ]
+            },
+            {
+                "path": "/updates",
+                "controller": "UpdatesCtrlRaw",
+                "http_methods": [
+                    "get"
+                ]
+            }
+        ],
+        //idle_connection_timeout: defaults to 60 seconds, the lifetime 
+        //of the connection without read or write
+        "idle_connection_timeout": 60,
+        //server_header_field: Set the 'server' header field in each response sent by drogon,
+        //empty string by default with which the 'server' header field is set to "Server: drogon/version string\r\n"
+        "server_header_field": "drogon",
+        //keepalive_requests: Set the maximum number of requests that can be served through one keep-alive connection. 
+        //After the maximum number of requests are made, the connection is closed.
+        //The default value of 0 means no limit.
+        "keepalive_requests": 0,
+        //pipelining_requests: Set the maximum number of unhandled requests that can be cached in pipelining buffer. 
+        //After the maximum number of requests are made, the connection is closed.
+        //The default value of 0 means no limit.
+        "pipelining_requests": 0,
+        //gzip_static: If it is set to true, when the client requests a static file, drogon first finds the compressed 
+        //file with the extension ".gz" in the same path and send the compressed file to the client.
+        //The default value of gzip_static is true.
+        "gzip_static": true,
+        //client_max_body_size: Set the max body size of HTTP requests received by drogon. The default value is "1M".
+        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
+        "client_max_body_size": "1M",
+        //client_max_websocket_message_size: Set the max size of messages sent by WebSocket client. The default value is "128K".
+        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
+        "client_max_websocket_message_size": "128K"
+    },
+    //plugins: Define all plugins running in the application
+    "plugins": [{
+        //name: The class name of the plugin
+        //"name": "TestPlugin",
+        //dependencies: Plugins that the plugin depends on. It can be commented out
+        "dependencies": [],
+        //config: The configuration of the plugin. This json object is the parameter to initialize the plugin.
+        //It can be commented out
+        "config": {
+            "heartbeat_interval": 2
+        }
+    }],
+    //custom_config: custom configuration for users. This object can be get by the app().getCustomConfig() method. 
+    "custom_config": {}
+}

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/config-raw.json

@@ -34,7 +34,7 @@
         //any synchronous interface of it.
         //any synchronous interface of it.
         "is_fast": true,
         "is_fast": true,
         //connection_number:1 by default
         //connection_number:1 by default
-        "connection_number": 8
+        "connection_number": 2
     }],
     }],
     "app": {
     "app": {
         //threads_num:the number of IO threads,1 by default, if the value is set to 0, the number of threads
         //threads_num:the number of IO threads,1 by default, if the value is set to 0, the number of threads

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/config.json

@@ -34,7 +34,7 @@
         //any synchronous interface of it.
         //any synchronous interface of it.
         "is_fast": true,
         "is_fast": true,
         //connection_number:1 by default
         //connection_number:1 by default
-        "connection_number": 8
+        "connection_number": 2
     }],
     }],
     "app": {
     "app": {
         //threads_num:the number of IO threads,1 by default, if the value is set to 0, the number of threads
         //threads_num:the number of IO threads,1 by default, if the value is set to 0, the number of threads