Live data from Hacker News

Nginx Unit – Universal web app server

github.com

181–190 of 201 posts

Re: Nginx Unit – Universal web app server

#182
post #67

I remember when they announced this a couple years ago I had no idea why I would use it over standard nginx. That seems to still be the case. It’s JSON controlled via Curl? And has a bunch of langue’s built in for some reason? The question becomes why?

This tool does have it's appeals to folks that run web applications behind web servers in containers.

For example, in this project we use nginx + php-fpm to serve some PHP app:

https://github.com/PrivateBin/docker-nginx-fpm-alpine

It uses s6 to handle nginx + php-fpm services, meaning we have to maintain configuration for s6 services (written in execline), nginx webserver configuration files (nginx proprietary format) and php-fpm (INI format).

I've created a fork that replaces that stack with nginx unit:

https://github.com/PrivateBin/docker-unit-alpine

No need for a service manager and both webserver and php configuration are in one file[1]. What is not well documented IMHO is that you don't have to load the config at runtime - if you place the JSON file in the (compile time changeable) /var/lib/unit directory it will be loaded on startup, similar to a traditional /etc config file. But it also will get updated at runtime, if configuration is uploaded on the config socket, making it persist service restarts, hence /var is more appropriate than /etc.

[1] https://github.com/PrivateBin/docker-unit-alpine/blob/master...

Re: Nginx Unit – Universal web app server

#183

Earlier quoted context omitted.

> a simple docker-compose Abstraction at it's finest.

Unironically this. After trying Kubernetes, Terraform, Ansible, and various proprietary PaaS config formats, I've grown to love Compose files' simplicity.

so I guess you are on Docker Swarm?

Re: Nginx Unit – Universal web app server

#184
post #67

I remember when they announced this a couple years ago I had no idea why I would use it over standard nginx. That seems to still be the case. It’s JSON controlled via Curl? And has a bunch of langue’s built in for some reason? The question becomes why?

This tool does have it's appeals to folks that run web applications behind web servers in containers. For example, in this project we use nginx + php-fpm to serve some PHP app: https://github.com/PrivateBin/docker-nginx-fpm-alpine It uses s6 to handle nginx + php-fpm services, meaning we have to maintain configuration for s6 services (written in execline), nginx webserver configuration files (nginx proprietary format…

> What is not well documented IMHO is that you don't have to load the config at runtime - if you place the JSON file in the (compile time changeable) /var/lib/unit directory it will be loaded on startup, similar to a traditional /etc config file. But it also will get updated at runtime, if configuration is uploaded on the config socket, making it persist service restarts, hence /var is more appropriate than /etc.

Thank you very much for this example, and calling out the config file option.

Do you find that you get any use from the config api in your setup (vs pushing a new container)?

I imagine it might be more useful if nginx unit acts like a k8s ingress like setup?

As for:

> both webserver and php configuration are in one file[1].

That's just the line in the Docker file:

  COPY --chown=${UID}:${GID} conf.json /var/lib/unit/
I found the actual file more illuminating:

https://github.com/PrivateBin/docker-unit-alpine/blob/master...

Re: Nginx Unit – Universal web app server

#185

This is really great! What I'm really look forward to trying is the server side WebAssembly: https://unit.nginx.org/configuration/#configuration-wasm . Huge potential!

What’s the advantage of server side WebAssembly over just running a Rust/whatever application?

As siblings have mentioned: sandboxing.

You don't need your language/runtime to support arm/other to run same compile artifact on arm32, arm64, power5 and amd64 - compile to wasm once, run anywhere (nginx unit would still need to support your target).

Your runtime theoretically don't need is support - compile to wasm, run on FreeBSD/arm.

You can compile your c microservice to wasm, and your rust microservice, and your c++ microservice to wasm - and deploy them sandboxed via the same stack - reducing complexity (note that another option is to deploy via nginx unit - different way to reduce complexity).

Re: Nginx Unit – Universal web app server

#187
post #126

Earlier quoted context omitted.

I too would like to see a properly configured php+php-fpm container benchmark. There's a lot of overhead when you link by http instead of a unix socket, in the same container.

Technically, you should be able to share a domain socket via a shared volume too (between an "app" and "web" container) - as with postgres: https://github.com/sameersbn/docker-postgresql/issues/30#iss... Curious about benchmarks and tests of TCP vs Unix domain sockets between docker containers.

I found a simple comparison from 2014 - which shows Unix domain sockets to have a 2-3x advantage over localhost TCP:

"Unix Domain Sockets vs Loopback TCP Sockets"

https://nicisdigital.wordpress.com/2014/03/03/unix-domain-so...

Hn submission: https://news.ycombinator.com/item?id=37466475

Re: Nginx Unit – Universal web app server

#188
post #41

This seems a lot more like how IIS works, unless I'm missing something? As an aside: it's always curious to see how the programming world has splintered into cliques that no longer hang out together. NGINX Unit is a "Universal" web server without support for C++, Rust, or ASP.NET! But PERL is supported, like the 1990s Linux cgi-bin world never went away.

Don't know about ASP.NET, but one of the supported languages is assembly, so I'd presume C++ and Rust can easily add a wrapper around that. > Binary-compiled languages in general: using the embedded libunit library. From https://unit.nginx.org/keyfeatures/#supported-app-languages

Thank you to link to that page. It is very funny. I highly recommend that others read it.

Choice quote:

    The benefits of using the assembly language for your web apps are immense:

    You get all the bragging rights: coding in assembly while everyone is working safe and secure within the confines of their precious sandboxed languages is like doing a perfect triple somersault without safety mats.
Next: I recommend multi-threaded assembly code with self-modifying code and lock free data structures!

Re: Nginx Unit – Universal web app server

#189
post #58

Earlier quoted context omitted.

YAML is an order of magnitude more hell...

But TOML is worse, right ? I can't write nor read TOML to save my life... :(

This is just my personal opinion, but I think YAML is more intuitive but has a lot more footguns and gotchas, while TOML is more consistent but less obvious (ironically, given the name.)

This may contribute to YAML's popularity in CI systems, because CI systems often need to be adjusted by someone who isn't super familiar with the syntax, and YAML is easier to intuit than TOML.

Re: Nginx Unit – Universal web app server

#190

Earlier quoted context omitted.

Unironically this. After trying Kubernetes, Terraform, Ansible, and various proprietary PaaS config formats, I've grown to love Compose files' simplicity.

so I guess you are on Docker Swarm?

Actually yeah! A single node is usually enough for me though, but I like the ability to throw in more nodes as needed (more or less painlessly, as long as you properly guard services that need persistent volumes with a label constraint).

Shameless plug: I also make a Docker Swarm dashboard, check it out: https://lunni.dev/

Post reply on HN