@@ -13,11 +13,27 @@ Collects read-write statistics for the entire storage and for each key.
1313| ** master** | [ ![ CI status] ( https://github.com/work-examples/key-value-web-server/actions/workflows/build_cmake.yml/badge.svg?branch=master )] ( https://github.com/work-examples/key-value-web-server/actions/workflows/build_cmake.yml?query=branch%3Amaster ) | [ ![ CodeQL Code Analysis Status] ( https://github.com/work-examples/key-value-web-server/actions/workflows/codeql-analysis.yml/badge.svg?branch=master )] ( https://github.com/work-examples/key-value-web-server/actions/workflows/codeql-analysis.yml?query=branch%3Amaster ) | [ ![ Microsoft C++ Code Analysis Status] ( https://github.com/work-examples/key-value-web-server/actions/workflows/msvc.yml/badge.svg?branch=master )] ( https://github.com/work-examples/key-value-web-server/actions/workflows/msvc.yml?query=branch%3Amaster ) |
1414| ** develop** | [ ![ CI status] ( https://github.com/work-examples/key-value-web-server/actions/workflows/build_cmake.yml/badge.svg?branch=develop )] ( https://github.com/work-examples/key-value-web-server/actions/workflows/build_cmake.yml?query=branch%3Adevelop ) | \[ not applicable\] | \[ not applicable\] |
1515
16- ## C++ Programmer's Test Task Description
16+ ## Contents
17+
18+ - [ C++ Programmer's Test Task Description] ( #task_description )
19+ - [ Server] ( #description_server )
20+ - [ Client Application] ( #description_client )
21+ - [ Task Implementation Remarks] ( #implementation_remarks )
22+ - [ Choosing Web Server Implementation] ( #choosing_web_server )
23+ - [ Other Implementation Features] ( #other_implementation_features )
24+ - [ Compile and Run] ( #compile_and_run )
25+ - [ Web API] ( #web_api )
26+ - [ Get Value] ( #api_get_value )
27+ - [ Set Value] ( #api_set_value )
28+ - [ Benchmark] ( #benchmark )
29+ - [ Testing Environment] ( #benchmark_environment )
30+ - [ Results] ( #benchmark_results )
31+
32+ ## C++ Programmer's Test Task Description <a name =" task_description " ></a >
1733
1834You need to write two applications, a client and a server, that communicate with each other.
1935
20- ### Server
36+ ### Server < a name = " description_server " ></ a >
2137
2238The server has a configuration file on disk (` config.txt ` ). It stores key/value data.
2339You can use any format. At startup, the server reads the configuration file.
@@ -52,7 +68,7 @@ writes=1
5268When developing, you can use third-party libraries for parsing and for the network.
5369For example ` rapidjson ` , ` boost ` etc.
5470
55- ### Client Application
71+ ### Client Application < a name = " description_client " ></ a >
5672
5773Single threaded. Connects to the server, then selects a random key
5874from the hardcoded list and executes ` $get ` on the server with a 99% probability,
@@ -63,9 +79,9 @@ Optionally make reconnect to the server in case of a disconnection, or if the se
6379i.e. the client waits until it appears on the network.
6480The client can be written in any language, even in Python.
6581
66- ## Task Implementation Remarks
82+ ## Task Implementation Remarks < a name = " implementation_remarks " ></ a >
6783
68- ### Choosing Web Server Implementation
84+ ### Choosing Web Server Implementation < a name = " choosing_web_server " ></ a >
6985
7086I decided to use well-known HTTP protocol for client-server communication.
7187Thus, we can easily debug the solution using any browser, programs like ` Postman ` .
@@ -91,7 +107,7 @@ I was choosing among many libraries:
91107
92108Finally, I settled on ` CrowCpp ` .
93109
94- ### Other Implementation Features
110+ ### Other Implementation Features < a name = " other_implementation_features " ></ a >
95111
96112The heart of the server engine uses `std::shared_mutex
97113to optimize performance for many readers and single writer.
@@ -115,7 +131,7 @@ compiled with included complex C++ templates.
115131
116132The solution also makes heavy use of move semantics.
117133
118- ## Compile and Run
134+ ## Compile and Run < a name = " compile_and_run " ></ a >
119135
1201361 . Run CMake.
1211372 . Compile project. You will get ` WebServer ` executable
@@ -133,14 +149,14 @@ CI is also preparing `Client.exe` executable which is a compiled version of `cli
133149python3 client.py
134150```
135151
136- ## Web API
152+ ## Web API < a name = " web_api " ></ a >
137153
138154Two API methods are supported.
139155
140156Here is the prepared API request collection for Postman:
141157[ WebServer.postman_collection.json] ( WebServer.postman_collection.json )
142158
143- ### Get Value
159+ ### Get Value < a name = " api_get_value " ></ a >
144160
145161` GET ` < http://127.0.0.1:8000/api/records/{key-name} >
146162
@@ -155,7 +171,7 @@ Reply body example:
155171}
156172```
157173
158- ### Set Value
174+ ### Set Value < a name = " api_set_value " ></ a >
159175
160176` POST ` < http://127.0.0.1:8000/api/records/{key-name} >
161177
@@ -175,9 +191,9 @@ Reply body example:
175191}
176192```
177193
178- ## Benchmark
194+ ## Benchmark < a name = " benchmark " ></ a >
179195
180- ### Testing Environment
196+ ### Testing Environment < a name = " benchmark_environment " ></ a >
181197
182198CPU Intel Core i5 (8th gen), mobile version, 8 logical cores.
183199Visual Studio 2019 (v16.11.13), Release build
@@ -192,7 +208,7 @@ WebServer.exe --no-logs
192208Client.exe --no-logs
193209```
194210
195- ### Results
211+ ### Results < a name = " benchmark_results " ></ a >
196212
197213| Number of <br />request threads | 10K requests <br />per thread, req/sec | 100K requests <br />per thread, req/sec |
198214| ---:| ------:| -------:|
0 commit comments