Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of github.com:crust-hub/tubekit
Browse files Browse the repository at this point in the history
  • Loading branch information
gaowanlu committed Apr 10, 2024
2 parents ee5f628 + ba2c1d4 commit 8a6191e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
42 changes: 20 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ support tcp keep-alive stream (protobuf) and http app (http-parser)、websocket

## Requests Per Second

CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60 GHz
Mem: 8GB
OS : WSL2 Ubuntu (Windows 11)
CPU: Intel(R) Core(TM) i5-9600KF CPU @ 3.70 GHz
OS : WSL2 Ubuntu Mem 8GB (Windows 11)

```ini
config/main.ini
theads:8
max_conn:2000
theads:6
max_conn:10000
```

apache2-utils testing
Expand All @@ -91,30 +90,29 @@ $ ab -c {{concurrency}} -n {{httpRequest}} http://IP:20025/
# apache2-utils ab report
concurrency bin/tubekit test/node_http_server.js httpRequest responseBodySize

10 11959.51/sec 3636.00 /sec 10000 890bytes
10 7897.85 /sec 3244.76 /sec 100000 890bytes
10 8050.12 /sec 3047.05 /sec 500000 890bytes
10 14051.34/sec 3004.74 /sec 10000 1072bytes
10 13594.83/sec 3456.10 /sec 100000 1072bytes
10 13208.49/sec 3519.01 /sec 500000 1072bytes

50 9571.97 /sec 3484.50 /sec 10000 890bytes
50 7679.47 /sec 3453.35 /sec 100000 890bytes
50 7744.02 /sec 3389.12 /sec 500000 890bytes
50 14080.68/sec 3860.68 /sec 10000 1072bytes
50 14643.93/sec 3852.66 /sec 100000 1072bytes
50 14618.96/sec 3827.33 /sec 500000 1072bytes

100 10784.61/sec 3819.69 /sec 10000 890bytes
100 7715.26 /sec 3447.19 /sec 100000 890bytes
100 7361.67 /sec 3566.64 /sec 500000 890bytes
100 13570.44/sec 3902.76 /sec 10000 1072bytes
100 14651.17/sec 3940.42 /sec 100000 1072bytes
100 14592.67/sec 3811.21 /sec 500000 1072bytes

500 7744.84 /sec 4101.63 /sec 10000 890bytes
500 7813.42 /sec 3593.05 /sec 100000 890bytes
500 7663.37 /sec 3654.70 /sec 500000 890bytes
500 13165.41/sec 3863.30 /sec 10000 1072bytes
500 14612.57/sec 3896.56 /sec 100000 1072bytes
500 14491.29/sec 3911.07 /sec 500000 1072bytes

1000 10670.04/sec 3381.92 /sec 10000 890bytes
1000 7682.88 /sec 3459.71 /sec 100000 890bytes
1000 7754.77 /sec 3667.54 /sec 500000 890bytes
1000 7519.90 /sec 3691.43 /sec 1000000 890bytes
1000 14195.35/sec 3271.67 /sec 10000 1072bytes
1000 14648.93/sec 3685.15 /sec 100000 1072bytes
1000 14601.71/sec 3879.07 /sec 500000 1072bytes
1000 14655.50/sec 3666.36 /sec 1000000 1072bytes
```

## Third-Party

1、[@http-parser](https://github.com/nodejs/http-parser) 2、[@lua](https://github.com/lua/lua)
3、[@protobuffer](https://github.com/protocolbuffers/protobuf) 4、[@openssl](https://github.com/openssl/openssl)

6 changes: 6 additions & 0 deletions src/connection/stream_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ bool stream_connection::buf2sock(bool &closed)
}
else
{
if (this->write_end_callback)
{
return this->write_end_callback(*this);
}
return false; // nothing m_waiting_send_pack to m_send_buffer
}
}
Expand Down Expand Up @@ -250,4 +254,6 @@ void stream_connection::reuse()
this->should_send_idx = -1;
this->should_send_size = 0;
this->sock2buf_data_len = 0;

write_end_callback = nullptr;
}
1 change: 1 addition & 0 deletions src/connection/stream_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace tubekit
buffer::buffer m_send_buffer;
buffer::buffer m_recv_buffer;
buffer::buffer m_wating_send_pack;
std::function<bool(stream_connection &connection)> write_end_callback{nullptr};

private:
int should_send_idx{-1};
Expand Down
5 changes: 5 additions & 0 deletions src/connection/websocket_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void websocket_connection::reuse()
this->m_wating_send_pack.set_limit_max(mem_buffer_size_max);

this->destory_callback = nullptr;
this->write_end_callback = nullptr;

http_parser_init(&m_http_parser, HTTP_REQUEST);
m_http_parser.data = this;
Expand Down Expand Up @@ -209,6 +210,10 @@ bool websocket_connection::buf2sock(bool &closed)
}
else
{
if (this->write_end_callback)
{
return this->write_end_callback(*this);
}
return false; // noting m_waiting_send_pack to m_send_buffer
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/connection/websocket_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ namespace tubekit
buffer::buffer m_send_buffer;
buffer::buffer m_wating_send_pack;

std::function<void(websocket_connection &connection)> destory_callback;
std::function<void(websocket_connection &connection)> destory_callback{nullptr};
std::function<bool(websocket_connection &connection)> write_end_callback{nullptr};

private:
int should_send_idx{-1};
Expand Down

0 comments on commit 8a6191e

Please sign in to comment.