In the ORC example benchmark from the Post about ORC the request doesn't use sessions.
I wonder how this example would look like, when request would need a) create sessions on demand b) Read/write to sessions made of complex GC data structures with refs and objects?
The code:
import asynchttpserver, asyncdispatch, strutils, json, tables, streams
# about 135 MB of live 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:
when not defined(memForSpeed):
GC_fullCollect()
waitFor server.serve(Port(8080), cb)
I made a wrong title mentioning the benchmark. My question was not so much about the benchmark part, but more about understanding how to use it.
I figured out how to use it in single thread mode, but still don't understand how it's supposed to be used in multi-thread mode.