Skip to content

Instantly share code, notes, and snippets.

@Araq
Created September 24, 2020 08:47
Show Gist options
  • Save Araq/7c17558d216488ad45fd6190507a9ad4 to your computer and use it in GitHub Desktop.
Save Araq/7c17558d216488ad45fd6190507a9ad4 to your computer and use it in GitHub Desktop.
import asynchttpserver, asyncdispatch, strutils, json, tables, streams
# about 130 MB of alive data:
var sessions: Table[string, JsonNode]
for i in 0..<10:
sessions[$i] = parseJson(newFileStream("1.json", fmRead), "1.json")
var served = 0
var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
inc served
await req.respond(Http200, "Hello World")
if served mod 10 == 0:
echo served, " MEM: ", formatSize getOccupiedMem()
GC_fullCollect()
waitFor server.serve(Port(8080), cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment