Urgent.News

What's breaking now, across thousands of outlets.

Tech

Concurrency Architecture in Lioran S3: Arc, Traits, Tokio and Backpressure

Concurrency Architecture in Lioran S3 Rust does not automatically make concurrent infrastructure correct. It gives you better tools for making ownership and synchronization explicit. Lioran S3 uses a relatively clear set of primitives: Arc dyn Trait Tokio async I/O Semaphore Mutex Atomics I’m Swaraj Puppalwar , Founder & CTO of Lioran Group and Lioran Developer Solutions . This article looks at…

Lioran S3's concurrency architecture in Rust does not automatically ensure correct concurrent infrastructure. Instead, it provides enhanced tools for making ownership and synchronization explicit. The key primitives used in this architecture include Arc, Dyn Trait, Tokio async I/O, Semaphore, Mutex, and Atomic.

The server maintains a cloneable ServerState object, with major components stored within Arc handles, such as metadata, object_engine, config, image_optimizer, video_upload_manager, video_pipeline, video_worker_pool, and metrics. Cloning request state avoids cloning the database or object engine; rather, it clones reference-counted handles.

The server relies on dyn MetadataStore and dyn ObjectEngine traits instead of hardwiring every caller to a concrete implementation. This separation allows for testing and future engine changes. For async file I/O, the server utilizes Tokio: tokio::fs::File AsyncRead AsyncReadExt AsyncWriteExt. This async I/O approach ensures that a worker thread does not need to block while waiting for network reads.

Backpressure is implemented using an Arc Semaphore called global_limiter. Each active part upload must acquire a permit, converting unlimited demand into bounded active work plus waiting. This prevents memory and descriptor usage from growing uncontrollably with incoming demand.

Multipart uploads own session_update_lock, an Arc Mutex, to handle shared upload-session state. While parts can stream concurrently, they eventually converge on shared metadata. AtomicBool is used for the graceful shutdown flag, which does not require a mutex around a boolean.

The architecture discourages global locks on hot paths. By allowing multiple request paths and subsystems to share the embedded metadata engine with Arc dyn MetadataStore, Lioran S3 avoids one global lock turning 64 concurrent requests into just 1 request doing work while 63 requests simply observe the mutex. Examples of bounded concurrency include the multipart global active-part count, maximum active upload sessions, RocksDB background jobs, media worker behavior, and bounded stream buffers.

This design principle aims for parallel work where work is independent, serialized where state must be coherent, and bounded where resources are finite.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Thursday 1 October →