2

I'm using Lua FASTCGI with Lighttpd. The Lua script is a thin wrapper around our C API which is being exposed to web. The problem is that Ajax calls execute one by one on the server side (instead of running in parallel) and it takes so much time. Some Ajax calls take up to 10 seconds and the browser cannot update any data while those calls are being executed.

I tried increasing the number of sever threads in Lighttpd but it is not recommended by Lighttpd. I don't know how to let multiple Ajax calls be executed at the server side in parallel.

finnw
  • 47,861
  • 24
  • 143
  • 221
AlexStack
  • 16,766
  • 21
  • 72
  • 104

1 Answers1

1

lighttpd can handle many requests in parallel, but your lua fastcgi thing probably can't. So don't increase the number of lighttpd workers - increase the number of lua workers instead, or make your lua backend handle multiple requests (perhaps with coroutines) at the same time.

Stefan
  • 5,304
  • 2
  • 25
  • 44
  • I will give co-routines a shot but as far as I know Lua doesn't have multi-threading by default. There is however a library called Lua Lanes that allows multi-threading. – AlexStack Jan 23 '13 at 14:59
  • 1
    yes, multithreading with one lua state doesn't work (coroutines won't help that); but it should be possible to run multiple lua "threads" (coroutines) in the same state in one os thread, and only run the lua "thread" if there is something to do. You said that it is waiting for network most of the time - so run other lua "threads" while you are waiting (async coding,callbacks). Also you can run different lua states in different os threads at the same time, states don't share anything from lua's point of view. – Stefan Jan 23 '13 at 15:32