Panagiotis Atmatzidis <atma / convalesco.org> wrote:
> On Sep 12, 2014, at 10:31, Eric Wong <normalperson / yhbt.net> wrote:
> > Panagiotis Atmatzidis <atma / convalesco.org> wrote:
> >> Generally speaking there is some latency in the server but doesn't
> >> justify almost 60+ seconds of difference :-/
> > 
> > I'd take a look at truss/ktruss/dtruss or whatever system call tracer
> > which gives timings on FreeBSD and see what syscalls take long.
> > Because based on the system+user times, it is waiting *something*
> > external.
> 
> Run a °∆dtruss°«. I didn°«t look at it carefully yet. I°«m not familiar with this kind of things, it will probably take me some time to figure out what°«s happening. Please take a look and let me know if there°«s anything that jumps out directly. What I found odd are the path errors are every call. I don°«t see those on my MacOSX system. NOTE: that°«s a 'dtruss -a°« output.
> 
> https://gist.github.com/atmosx/93e7f202539d8d8a0d47

As Ryan pointed out, select is taking a long time so that means it's
waiting on I/O of some sort.  Unfortunately your dtruss output isn't
outputting more detail about which FDs select is waiting on.

I would look into more verbose tracing options of dtruss
(probably equivalent to "strace -v -T" for Linux).

One more thing: have you checked if the api.skroutz.gr endpoint is
throttling your server IP for giving it too much traffic?

> > I would also take a look at the Faraday gem + dependencies which it
> > seems to use for HTTP access.  It could be misconfigured TCP knobs
> > (TCP_NODELAY may be needed, or forgot to uncork the socket on
> > TCP_NOPUSH).
> > 
> > I suppose you can also try doing the equivalent with the excellent
> > Net::HTTP::Persistent gem  .

> I tried using °∆open-uri°« to do download a file of 1024kb side.
> Net:Http made about 12s while OpenURI about 22s not that system.

s/not that system/on that system/ ?