@@ -13,6 +13,8 @@ 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+ <a name =" content " ></a >
17+
1618## Contents
1719
1820- [ C++ Programmer's Test Task Description] ( #task_description )
@@ -29,11 +31,15 @@ Collects read-write statistics for the entire storage and for each key.
2931 - [ Testing Environment] ( #benchmark_environment )
3032 - [ Results] ( #benchmark_results )
3133
32- ## C++ Programmer's Test Task Description <a name =" task_description " ></a >
34+ <a name =" task_description " ></a >
35+
36+ ## C++ Programmer's Test Task Description
3337
3438You need to write two applications, a client and a server, that communicate with each other.
3539
36- ### Server <a name =" description_server " ></a >
40+ <a name =" description_server " ></a >
41+
42+ ### Server
3743
3844The server has a configuration file on disk (` config.txt ` ). It stores key/value data.
3945You can use any format. At startup, the server reads the configuration file.
@@ -68,7 +74,9 @@ writes=1
6874When developing, you can use third-party libraries for parsing and for the network.
6975For example ` rapidjson ` , ` boost ` etc.
7076
71- ### Client Application <a name =" description_client " ></a >
77+ <a name =" description_client " ></a >
78+
79+ ### Client Application
7280
7381Single threaded. Connects to the server, then selects a random key
7482from the hardcoded list and executes ` $get ` on the server with a 99% probability,
@@ -79,9 +87,13 @@ Optionally make reconnect to the server in case of a disconnection, or if the se
7987i.e. the client waits until it appears on the network.
8088The client can be written in any language, even in Python.
8189
82- ## Task Implementation Remarks <a name =" implementation_remarks " ></a >
90+ <a name =" implementation_remarks " ></a >
8391
84- ### Choosing Web Server Implementation <a name =" choosing_web_server " ></a >
92+ ## Task Implementation Remarks
93+
94+ <a name =" choosing_web_server " ></a >
95+
96+ ### Choosing Web Server Implementation
8597
8698I decided to use well-known HTTP protocol for client-server communication.
8799Thus, we can easily debug the solution using any browser, programs like ` Postman ` .
@@ -107,7 +119,9 @@ I was choosing among many libraries:
107119
108120Finally, I settled on ` CrowCpp ` .
109121
110- ### Other Implementation Features <a name =" other_implementation_features " ></a >
122+ <a name =" other_implementation_features " ></a >
123+
124+ ### Other Implementation Features
111125
112126The heart of the server engine uses `std::shared_mutex
113127to optimize performance for many readers and single writer.
@@ -131,7 +145,9 @@ compiled with included complex C++ templates.
131145
132146The solution also makes heavy use of move semantics.
133147
134- ## Compile and Run <a name =" compile_and_run " ></a >
148+ <a name =" compile_and_run " ></a >
149+
150+ ## Compile and Run
135151
1361521 . Run CMake.
1371532 . Compile project. You will get ` WebServer ` executable
@@ -149,14 +165,18 @@ CI is also preparing `Client.exe` executable which is a compiled version of `cli
149165python3 client.py
150166```
151167
152- ## Web API <a name =" web_api " ></a >
168+ <a name =" web_api " ></a >
169+
170+ ## Web API
153171
154172Two API methods are supported.
155173
156174Here is the prepared API request collection for Postman:
157175[ WebServer.postman_collection.json] ( WebServer.postman_collection.json )
158176
159- ### Get Value <a name =" api_get_value " ></a >
177+ <a name =" api_get_value " ></a >
178+
179+ ### Get Value
160180
161181` GET ` < http://127.0.0.1:8000/api/records/{key-name} >
162182
@@ -171,7 +191,9 @@ Reply body example:
171191}
172192```
173193
174- ### Set Value <a name =" api_set_value " ></a >
194+ <a name =" api_set_value " ></a >
195+
196+ ### Set Value
175197
176198` POST ` < http://127.0.0.1:8000/api/records/{key-name} >
177199
@@ -191,9 +213,13 @@ Reply body example:
191213}
192214```
193215
194- ## Benchmark <a name =" benchmark " ></a >
216+ <a name =" benchmark " ></a >
195217
196- ### Testing Environment <a name =" benchmark_environment " ></a >
218+ ## Benchmark
219+
220+ <a name =" benchmark_environment " ></a >
221+
222+ ### Testing Environment
197223
198224CPU Intel Core i5 (8th gen), mobile version, 8 logical cores.
199225Visual Studio 2019 (v16.11.13), Release build
@@ -208,7 +234,9 @@ WebServer.exe --no-logs
208234Client.exe --no-logs
209235```
210236
211- ### Results <a name =" benchmark_results " ></a >
237+ <a name =" benchmark_results " ></a >
238+
239+ ### Results
212240
213241| Number of <br />request threads | 10K requests <br />per thread, req/sec | 100K requests <br />per thread, req/sec |
214242| ---:| ------:| -------:|
0 commit comments