local url = 'http://example.com'
local gettime = require 'socket'.gettime
local conn = require 'socket.http'
local start = gettime()
local r, s = conn.request(url)
print(gettime() - start)
Not sure what the cause may be in your case. Perhaps your browser has cached the result and that's why it seems to respond much quickly.
Well i should have tested it with another api before opening the thread, your example runs pretty fast in my machine too. I think the problem is json-server, for some reason it is slow when called from socket.http.