heart

command module
v0.0.0-...-aa1fe35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

README

Heart 💜

A high performance Lua web server with a simple, powerful API. See the full documentation here.

Check out redbean!

If you like Heart then you'll probably love redbean. It's a very similar concept but arguably executed and documented better.

Overview

Heart combines Go's fasthttp with LuaJIT to create an insanely fast Lua web server.

It also comes with a performant key-value store API backed by BadgerDB that can store data both in memory and on disk.

Features

  • High throughput
  • Low latency
  • Fast K/V store
  • Versioned API
  • Stable Lua 5.1 VM
  • Structured logs

Getting Started

  • Create a Lua file that uses the Heart API
-- main.lua
local app = require('heart.v1')

app.get('/:name', function(ctx)
  return 'Hello, ' .. ctx.pathParam('name') .. '!'
end)
  • Run Heart with Docker and point it at your Lua docker run -v $(pwd):/root/app -p 3333:3333 hyperspacelogistics/heart:latest app/main.lua
  • curl localhost:3333/world to see the result
  • Congratulations you're running a wicked fast Lua server 🎊

Benchmark

Benchmark

Each stack was tasked with rendering {"hello": "world"} through their JSON stack in production mode, if applicable, with logging disabled. wrk was used with the command wrk -t32 -c512 -d30s http://localhost:3333. All benchmarks were performed on a CPU-optimized DigitalOcean droplet that had 32vCPUs and 64 GB of RAM.

Caveats

Global state, like with any parallel web server, is highly discouraged. For performance reasons Heart keeps a pool of Lua state to reuse in subsequent requests. State is reused in a random order and therefore global state that is modified in requests is functionally random in Heart. Be cautious! Static global state is the exception and can generally be treated as safe.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package las is lua associated state functionally it's just a module isolating a map of *lua.State to more *AssociatedState
Package las is lua associated state functionally it's just a module isolating a map of *lua.State to more *AssociatedState

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL