Show HN: Redbean – Single-file distributable web server


redbean
single-file distributable web server

redbean makes it that you just might per chance well per chance per chance keep in mind to share web applications that speed offline
as a
single-file αcτµαlly
pδrταblε εxεcµταblε
zip archive which contains your resources. All
or now not it’s miles a have to to construct is get the redbean.com program below,
commerce the filename to .zip, add your swear in a zip instrument like
Windows 10 or InfoZIP, and commerce the extension aid to .com.

redbean can serve 1 million+ gzip encoded responses per 2nd on a
low-label interior most computer. That performance is thanks to zip and gzip
the usage of the identical compression structure, which enables kernelspace copies.
But some other reason redbean goes speedily is that or now not it’s miles a little static binary,
which makes fork memory paging with regards to free.

redbean is additionally easy to alter to compare your have wants. This system
itself is written as a single .c file.


get
 







redbean-2021-02-25.com
200kb – PE+ELF+MachO+ZIP+SH

redbean-2021-02-25.com.dbg
2.2m – ELF debugger data (optional)

redbean.c
source code


capabilities

  • HTTP v1.1
  • Divulge-Encoding
  • Differ / Divulge-Differ
  • Final-Modified / If-Modified-Since


set up

curl https://justine.lol/redbean/redbean-most contemporary.com>redbean.com
chmod +x redbean.com
bash -c './redbean.com -vv'


usage

echo '&ltb>hi there&lt/b>'>index.html
zip redbean.com index.html
./redbean.com -vv
curl -v http://127.0.0.1: 8080/index.html


crucial points

Resources could well per chance also be listed by working the following dispute:

unzip -vl redbean.com        # lists recordsdata

Resources could well per chance also be added to the zip archive as follows:

zip redbean.com index.html   # provides file

By default, one thing else you add to the archive gets compressed. In most cases
you gain now not need that to happen. A dependable example is video recordsdata. The salvage
browser will desire to ship HTTP differ requests to witness in the video, in
which case redbean requires that the asset be uncompressed.

zip -0 redbean.com video.mp4  # provides file without compression

Each and every connection makes use of a time limit snapshot of your ZIP file.
In case your ZIP is deleted then serving continues. If or now not it’s replaced
then issuing SIGUSR1 (or SIGHUP if daemon) will reindex the zip
for subsequent connections without interrupting entertaining ones. If
SIGINT or SIGTERM is issued then a swish shutdown is started
however if or now not it’s issued a 2nd time, entertaining connections are reset.


flags

-h serve
-v verbosity
-d daemonize
-s uniprocess
-m log messages
-c INT cache seconds
-r /X=/Y redirect X to Y
-l ADDR listen ip [default 0.0.0.0]
-p PORT listen port [default 8080]
-L PATH log file quandary
-P PATH pid file quandary
-U INT daemon assign user identity
-G INT daemon assign neighborhood identity
-B STR adjustments server header

benchmark

$ wrk -H 'Settle for-Encoding: gzip' -t 12 -c 120 
  http://127.0.0.1: 8080/instrument/salvage/redbean.html
Running 10s take a look at @ http://127.0.0.1: 8080/instrument/salvage/redbean.html
  12 threads and 120 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   745.49us    8.79ms 406.77ms   99.54%
    Req/Sec    96.60ample     6.10ample  123.66ample    77.36%
  11631210 requests in 10.10s, 7.96GB be taught
Requests/sec: 1151621.71
Switch/sec:    807.23MB


peek additionally

justine’s web page online
αcτµαlly pδrταblε εxεcµταblε

Read More

Similar Products:

Recent Content