Pārlūkot izejas kodu

Update Lithium to fix mysql connection errors. Tune the number of mysql connections. (#5318)

* [new c++ framework] Lithium.

* Some cleanup.

* [lithium ] Add test to travis.

* Update lithium.

* Update lithium.

* Update lithium.

* Update Lithium. Tune the number of mysql connections.

* Update Lithium. Tune the number of mysql connections.
Matthieu Garrigues 5 gadi atpakaļ
vecāks
revīzija
0ff2f505a2

+ 4 - 1
frameworks/C++/lithium/lithium.cc

@@ -37,6 +37,9 @@ int main(int argc, char* argv[]) {
       mysql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
                      s::password = "benchmarkdbpass", s::port = 3306, s::charset = "utf8");
 
+  int mysql_max_connection = mysql_db.connect()("SELECT @@GLOBAL.max_connections;").read<int>() * 0.75;
+  li::max_mysql_connections_per_thread = (mysql_max_connection / nprocs);
+
   auto fortunes = sql_orm_schema(mysql_db, "Fortune").fields(
     s::id(s::auto_increment, s::primary_key) = int(),
     s::message = std::string());
@@ -112,7 +115,7 @@ int main(int argc, char* argv[]) {
     response.set_header("Content-Type", "text/html; charset=utf-8");
     response.write(ss.str());
   };
-  
+
   http_serve(my_api, port, s::nthreads = nprocs);
   
   return 0;

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

@@ -6,7 +6,7 @@ RUN apt install -yqq libboost-context-dev
 
 COPY ./ ./
 
-ENV COMMIT=032430958169d97798642904072c5e3a8d2c55fe
+ENV COMMIT=8399f065741cbf2060f8f91b451fe8391b852664
 
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_mysql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh