Skip to content

Submission: Rust actix-web template #141

Open
@baremaximum

Description

Hi,

I would like to submit a proposal for an openfaas template that uses the actix-web framework in Rust. Here is a link to the repo containing the template: https://github.com/baremaximum/rust-actix-web-template

Why I made this template

While there are some Rust templates, none of them take full advantage of the strengths of the HTTP watchdog.

The HTTP template that does exist (https://github.com/openfaas-incubator/rust-http-template) doesn't work. Even if it did, it uses the low-level 'hyper' crate. This crate provides a correct HTTP implementation that is meant to serve as the basis for building web frameworks or clients. As a result, it is lacking many of the features that you would find in a fully fleshed out framework. For example, it doesn't implement any kind of multi-threading. It also doesn't provide any means to persist objects between requests/threads. Any user that wants to use multi-threading, or that wants to maintain a persistent database connection pool, would be discouraged to learn that they have to write that functionality themselves. Unfortunately, these features are some of main reasons to use of-watchdog templates. I don't think it makes sense for a template to make it that difficult use the watchdog's advantages.

I made this template to provide an alternative that doesn't have these limitations.

Why actix-web (pros)?

Actix-web is a popular, high performance, fully featured web framework written in Rust. It's about as fast as it gets (see benchmarks ). Compared to NodeJS, an actix-web server can serve ~7 times as many requests per second under heavy load, at a small fraction of the cost (see this article ). It also has a near instantaneous ( <1ms) start-up time, and a tiny binary size. The image built from this template is less than 40 mb,, which is less than 20 mb more than the base alpine + of-watchdog image. As a result, actix-web is perfectly suited for situations where rapid and efficient scaling is required.

All of these factors combine to make actix-web a very attractive candidate for writing HTTP functions.

Why not actix-web (cons)?

Rust is less popular than most of the other languages used by openfaas templates.. As a result, the community is smaller, and there aren't as many "battle-tested" libraries.

Using an HTTP framework means that users will have to modify files in the template most of the time, instead of just modifying the handler. This results in an awkward workflow and potentially bloated directory structure. Unfortunately, it's inherently impossible to make a single application that meets everyone's needs. Middleware, and plugin requirements for example are likely to change on different projects, and these are never set at the handler level. However, this problem isn't unique to this template.

Finally...

If you read all of that, thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions