Robyn Web Server: Architecture Overview
Robyn is a unique Python web server, leveraging the efficiency and concurrency model of the tokio runtime.
Worker Event Cycle:
At the heart of Robyn is the worker event cycle that oversees the runtime and directs all instructions to the underlying Rust code. This cycle is instrumental in initializing the thread pool, ensuring smooth execution.
Python-to-Rust Interplay:
When the server is initiated with the python3 app.py command, Python code is dynamically transformed into Rust objects. Subsequently, the router gets populated. The architecture allows incoming requests to be matched against this router, and relevant Rust objects are queued for execution in the thread pool based on their types.
Scalability with Multi-Core Support:
Robyn is designed to scale efficiently. It has the capability to employ multiple workers and span across multiple processes. This architecture facet ensures that the TCP socket can distribute its load across various cores, optimizing performance.
Const Requests: The Robyn Speciality:
Const Requests is a feature that sets Robyn apart. Instead of executing a function every time it's called, what if we could run it once and cache the response? This would substantially reduce overhead, negating the need to frequently call the router.
Const Request Optimisation: This feature aims to store function responses in the Rust layer after their initial execution. Thus, when the same function is called again, the cached result from Rust is returned, bypassing the router.