OPERATING SYSTEMSOS Linux

Cargo Foundations Rust Library by Cloudflare

Cloudflare introduced a foundational library earlier this year. Its purpose is to streamline your application’s transition into production. This is often a challenging stage involving various components like logging, metrics, and telemetry.

Install into your Cargo.toml with `cargo add foundations` command.

The library is designed to facilitate production-grade performance, a critical factor. Also, Cloudflare has open-sourced it, making it available for our use. Interestingly, it’s written in Rust, a language that has been gaining traction for quite some time now, due to its focus on scale, performance, memory safety, and concurrency safety.

A significant number of bugs experienced during product launch are often due to concurrency, race conditions, and memory errors. Rust prevents these problems by disallowing the compilation of apps that could trigger such errors. This explains why Cloudflare is focusing on Rust for their libraries and open-sources.

What’s unique about Cloudflare’s foundational library are its features. Among them, you’ll find logging, tracing, metrics, and memory profiling. Each feature intended to create a proficient production-level system.

There’s even an additional security layer, syscall sandboxing, a tool I find particularly intriguing. I noticed an overlap concerning API route definitions and config files. Having to define the same thing twice seems redundant, resulting in extra maintenance.

The system’s server should ideally have a built-in functionality to return a YAML file format with all the information about the system. This would eliminate the need for inputing this information manually. The beauty of this library is that it takes into account all essential production aspects.

Performance, which is crucial for production systems, has been given special priority, enabling the system to handle production workloads. All features have been designed to be modifiable via cargo features. There are also allowances for adding or removing various functionalities like metrics, logging, and tracing.

A bonus for system optimization. A feature that stands out to me is security. Particularly, the syscall sandboxing.

It restricts the range of system calls your process can make, allowing only allowed system calls to pass. In the event of an unauthorized activity, the process gets terminated immediately and restarts from scratch. Oh, wait! They do provide built-in settings configurations similar to how I hoped.

Initially, I misjudged it to imply maintaining YAML and source code simultaneously. But, in reality, the settings file generates all routes, status response codes, and subsequently creates a YAML file. You no longer have to maintain a separate config file.

This, I must say, was a pleasant surprise. Cloudflare’s foundational library is worth a look. It streamlines the process of creating an application and satisfies all the necessity of a production-grade application.

This library almost seems like a framework, you can utilize component parts of it in your existing framework or application. Besides, who doesn’t love a lightweight, easy-to-maintain application foundation?

source

by Stephen Blum

linux foundation