auth_server /login api, with coroutines running, database checks & updates, 550 login requests/s
Common code libraries and setups for distributed system server nodes put behind reverse proxies.
Ideally the reverse proxies will do the security and rate limitations for you, saving you dev time to focus on other things.
Dependency on libuv for timers, sockets/udp/tcp, event loops and threading.
-
sample_server: Sample TCP server with multiple examples, a single tcp server example, another multithreaded example, and an incomplete forked child process version.
-
alt_program: TCP Client
-
sample_http_server: Sample http server supporting only JSONRPC capability
-
auth_server: Sample authentication server with login endpoint and restricted endpoint, using JWT for authentication, libpq connection to database, coroutines
-
prometheous_test: sample server endpoint for prometheus monitoring tools
Development with WSL
- WSL, VSCode (preferred). Follow the following linux instructions
Linux
-
apt-getpackages: g++, make, build-essentials, libuv1-dev -
for
auth_server: libpq and libjwt-dev,apt-get postgresqlfor database, Then run db script inauth_server/db_scriptslike so:psql -U postgres -h localhost -d postgres -f db_scripts/reset_and_seed.sql -
apt-get install libuv1-dbgsymfor debugging libuv
-
Make sure you have vscode installed, open a cmd prompt at the base path, type
bashto log into wsl, thencode . -
Make sure you can see a
WSL:Ubuntuat the bottom left -
you can modify what to build in
.vscode/tasks.jsonunder the"command"keyword -
you can modify which executable to run in
.vscode/launch.jsonunder the"program"keyword
-
Open a linux terminal in whatever ide you have, run
make -
to clean
make clean
- Built outputs should be located in the subfolder. You can place your config files there.
- You can add new services at the base
Makefileby adding a subdir and source files. Polyglot languages are allowed as long as they have a makefile and the appropriate packages installed
-
Server Logging with automated rotations
-
Http parser picohttpparser
-
Json Parser/Serializer (yyjson)
-
Performance statistics html page generation and performance measuring/tracking
-
tcp/http server setups, with asynchronous jobs
-
Authentication using JWT, check
auth_server
Good prompts for AI:
-
"how fast is forwarding a request from nginx to a localhost server" Answer: 0.2ms to (under) 1ms
-
"how fast is a mutex lock" Answer: if uncontested, 10–40 nanoseconds, If another thread is using the lock, the operating system must step in to park the waiting thread. This context switch requires a trip into kernel space, costing 1,000 to over 10,000 clock cycles (frequently 500+ nanoseconds
-
"what are nginx's size limits for http?" - controls size input
-
"tuning a libuv tcp server"
-
"how fast can database queries and updates range from"
-
apt install inetutils-telnetand thentelnet 127.0.0.1 <port>for sending tcp messages -
use your browser, navigate to
http://127.0.0.1:<port>to send http messsages -
apt install apache2-utilsabd thenab -n 10000 -c 100 http://localhost:3000/to blast messages/loadtest
-
Prompt "libuv event loop", ask what function calls map to what parts of the loop. Notably, the Poll I/O dynamically calculates a timeout
Public Domain