Skip to content
/ luz Public

Building blazing fast APIs and micro-services

License

Notifications You must be signed in to change notification settings

hide2/luz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

luz - Building blazing fast APIs and micro-services

luz gets 3X performance of Nodejs, 4.5X of Express, 18X of Lumen.

See benchmark result of the same "hello" example with single process:

  • luz: 27000 #/sec
  • Node.js: 9000 #/sec
  • Express: 6000 #/sec
  • Lumen: 1500 #/sec

Install

Usage

  • hello.lua
local app = require("./luz/app").app:new()

app:get('/', function()
	return "hello"
end)
app:listen({port=8001})

print("Http Server listening at http://0.0.0.0:8001/")

Run:

luvit hello.lua
  • echo.lua(with routing and JSON codec)
local app = require("./luz/app").app:new()
local JSON = require('rapidjson')

app:get('/echo/:msg', function(params)
	return JSON.encode({ msg = params.msg})
end)
app:listen({port=8002})

print("Http Server listening at http://0.0.0.0:8002/echo/:msg")
  • user.lua(with routing and JSON codec and SQLite)
local db = require("./luz/db").DB:new("sqlite3", "/tmp/test.sqlite3")
local User = require("./luz/db").Model:extend():new(db)
local app = require("./luz/app").app:new()
local JSON = require('rapidjson')

-- prepare db
User.db:run"DROP TABLE user"
User.db:run[[
  CREATE TABLE user(
    id  INT PRIMARY KEY,
    name  VARCHAR(50),
    email VARCHAR(50)
  )
]]
local list = {
  { id=1, name="Jose das Couves", email="jose@couves.com", },
  { id=2, name="Jack", email="manoel.joaquim@cafundo.com", },
  { id=3, name="Jack", email="maria@dores.com", },
}
for i, p in pairs (list) do
  User:save({id=p.id, name=p.name, email=p.email})
end

app:get('/user/:id', function(params)
  local user = User:find(params.id)
  return JSON.encode(user)
end)
app:listen({port=8003})

print("Http Server listening at http://0.0.0.0:8003/user/:id")

Benchmark

About

Building blazing fast APIs and micro-services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages