Git Product home page Git Product logo

nxweb's Introduction

= NXWEB =

Ultra-fast and super-lightweight web server for applications written in C.

== Home Page ==

Project home page: [[http://nxweb.org|NXWEB.ORG]]

== Rationale ==

Sometimes web applications need small and fast components that are best written in C.

Example: ad banner rotation engine. It gets invoked many times on every page of your site producing little HTML snippets based on predefined configuration. How would you implement it?

CGI is not an option as it gets loaded and unloaded on every request. Writing a module for your main web server such as Apache httpd or nginx gives best performance but server's API isn't very friendly (especially when dealing with shared memory, etc.). What we need is sort of servlet container for C (just like Java has).

Before writing NXWEB I evaluated a number of existing light/embeddable web servers (mongoose, microhttpd, libevent, G-WAN) each one having their own drawbacks (see notes to [[Benchmarks|benchmarks]]).

=== What NXWEB offers:

* good (if not best) **performance**; see [[Benchmarks|benchmarks]]
* can serve thousands concurrent requests
* small memory footprint
* event-driven & multi-threaded model designed to scale
* exceptionally light code base
* **simple API**
* decent HTTP protocol handling
* keep-alive connections
* chunked requests and responses
* **SSL support** (via GNUTLS)
* **HTTP proxy** (with keep-alive connection pooling)
* **file cache** for proxied content and custom handlers' output
* cached content can be served when backend is unavailable
* non-blocking sendfile support (with configurable small file memory cache)
* cacheable **gzip** content encoding
* cacheable **image thumbnails** with watermarks (via ImageMagick)
* basic server-side includes (**SSI**)
* **templating engine** with page inheritance
* subrequests
* integrated **Python WSGI-server**
* modular design for developers
* can be run as daemon; relaunches itself on error
* open source

=== Limitations:

* only tested on Linux

== Architecture ==

Main thread binds TCP port, accepts connections and distributes them among network threads.

//Network threads// work in non-blocking fashion (using epoll) handling HTTP protocol exchange. There should be no need in using more network threads than the number of CPU cores you have, as every thread is very efficient and can easily handle thousands of concurrent connections. Numbers of network threads is automatically configured but could be limited by {{{#define NXWEB_MAX_NET_THREADS}}} directive.

After receiving complete HTTP request network thread finds and invokes application's //URI handler//. The invocation could happen within network thread (should only be used for quick non-blocking handlers) or within worker thread (should be used for slower or blocking handlers).

//Worker threads// are organized in pool. Each thread takes new job from queue, invokes URI handler, signals network thread after handler completes the job. Number of worker threads is dynamically configured depending on the load with limits specified by #define directives.


== API

See [[http://nxweb.org|official website]] and [[https://bitbucket.org/yarosla/nxweb/src|source code]]. {{{hello.c}}} is an example of user module. {{{nxweb.h}}} contains function and struct definitions.

== Benchmarks

See [[Benchmarks|NXWEB benchmarks here]].

== Building from source

# Download archive [[https://bitbucket.org/yarosla/nxweb/downloads|from here]]
# Follow INSTALL file notes

== Issues

Please report issues via [[https://bitbucket.org/yarosla/nxweb/issues|issue tracker]].

== Discussions & Announcements

**nxweb**\\
[[http://groups.google.com/group/nxweb?hl=en|Visit this group]]

**nxweb-ru** (in Russian)\\
[[http://groups.google.com/group/nxweb-ru?hl=ru|Visit this group]]

nxweb's People

Contributors

colemancda avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.