On Thu, Jan 13, 2011 at 6:47 PM, Eric Wong <[email protected]> wrote:
> [email protected] wrote:
>> On Thu, Jan 13, 2011 at 3:06 PM, Eric Wong <[email protected]> wrote:
>> > [email protected] wrote:
>> > How does lsof output look for your workers?
>>
>> Hm. The workers seem to be at 80-90 file descriptors each. I did catch
>> one at 787 (!) with mostly handles to a geoip database from the geoip
>> gem, but they got collected pretty quickly. Perhaps that's the cause!
>
> OK, that's a fairly likely cause of EMFILE.
>
> A tip for geoip users:
>
> Install the io-extra gem to get IO.pread. This allows you to reuse
> the same file descriptor with geoip automatically between any number
> of threads/processes without reopening it.
Fascinating. Google tells be you've been down this road before. My
code previously was doing:
def get_city(ip)
GeoIP.new("/path/to/geo.dat").city(ip)
end
Which seems to create one fd per call (and leave it for the GC to
cleanup). What's the new proposed interface if io-extra is installed?
Keep a global GeoIP object somewhere? My fix was to stuff it in to
Thread.current, but obviously that has one fd per thread.
-Greg
_______________________________________________
Unicorn mailing list - [email protected]
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying