db-lab1/README.md

84 lines
1.2 KiB
Markdown
Raw Normal View History

2021-03-05 15:39:47 +08:00
# bserv
*A Boost Based High Performance C++ HTTP JSON Server.*
## Dependencies
- [Boost 1.75.0](https://www.boost.org/)
- [PostgreSQL 13.2](https://www.postgresql.org/)
- [Libpqxx 7.3.1](https://github.com/jtv/libpqxx)
- [Crypto++ 8.4.0](https://cryptopp.com/)
- CMake
## Quick Start
### Database
You can import the sample database:
- Create the database in `psql`:
```
create database bserv;
```
- Create the table in the `shell` using a sample script:
```
psql bserv < db.sql
```
2021-08-08 08:56:35 +08:00
### Server & Routing
2021-03-05 15:39:47 +08:00
2021-08-08 08:56:35 +08:00
Configure server & routing in [main.cpp](main.cpp).
2021-03-05 15:39:47 +08:00
### Handlers
Write the handlers in [handlers.hpp](handlers.hpp)
## Build
2021-03-13 19:48:34 +08:00
In the `shell`:
- Create a directory `build`, and enter it:
```
mkdir build
cd build
```
- Run:
```
cmake ..
```
- Build:
```
cmake --build .
```
2021-03-05 15:39:47 +08:00
## Running
2021-03-13 19:48:34 +08:00
In `build`, run in `shell`:
2021-03-05 15:39:47 +08:00
```
2021-03-13 19:48:34 +08:00
./bserv
2021-03-05 15:39:47 +08:00
```
## Performance
2021-03-13 19:33:01 +08:00
This test is performed by Jmeter. The unit for throughput is Transaction per second.
2021-03-05 15:39:47 +08:00
2021-03-13 19:33:01 +08:00
|URL|bserv|
|:-:|:-:|
|`/login`|139.55|
|`/find/<user>`|958.77|
2021-03-05 15:39:47 +08:00
2021-03-13 19:48:34 +08:00
For `/login`, we intentionally slow down the attacker's speed.
2021-03-05 15:39:47 +08:00
### Computer Hardware:
- Intel Core i9-9900K x 4
- 16GB RAM