Speed comparison of Postgresql modules for nginx Openresty

For an application we are working on that will track user interactions with things, we need the fastest possible solution in order not to slow down the other end (too much).

So I benchmarked the different PostgreSQL modules available for Openresty. Openresty is Nginx with LuaJit and other powerful features. It is very interesting because it is very fast and light.

For this test, I used a single SELECT * query on a very small table. The server was running on our old test server and the server making the requests was plugged on the same router, so there was no significant network latency due to the Internet.

The fastest solution was ngx_postgres. My 1000 times loop took 1.3 sec. The second fastest solution was lua-resty-postgres which took 1.8 sec. And then, I tested pgmoon which took 4.4 sec. I guess it was slower because it does type conversion in Lua, although I am not sure that this is the only reason.

This test was done with our Hawk authentication system.

This entry was posted in life. Bookmark the permalink.

Comments are closed.