You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This limits windows as a platform for running large scale applications such as eventmachine.
Could we please set FD_SETSIZE to a considerably large limit in the makefile, say 99999, to allow for larger scale applications. Currently it is quite useless.
Can you be more specific? Which version of Ruby are you talking about? For 1.8.x we used to increase FD_SIZE to 256. Ruby 1.9 does not suffer from that.
Basically libraries such as eventmachine require it to be set otherwise they are limited to 64 sockets which is pretty meaningless and considering I've been doing production deployments using EM and thin on windows it is pretty scary.
I've been hacking at Eventmachine for the last 2 days as I have application that is using ~150 sockets now and is intended to scale well beyond 1000 before the end of the year.
Right now it is 3am here and I'm configuring a Linux VM to NAT with the windows host so I don't hit the 64 limit. I would prefer not to be doing this again in a couple of months after I've reached the 256 limit...
There are 16383 ephemeral ports on windows (ie the probable max an application will ever use) can we use that?
The maximum number of sockets that a Windows Sockets application can use is not affected by the manifest constant FD_SETSIZE.
But, further reading:
This value defined in the Winsock2.h header file is used in constructing the FD_SET structures used with select function. The default value in Winsock2.h is 64. If an application is designed to be capable of working with more than 64 sockets using the select and WSAPoll functions
We can up that numbre to 32767, which seems to be the maximum supported by iMaxSockets
If you agree, I'll change 1.9 recipe so next build will handle that.
@stakach hehe..yeh, I know the 64 number is the number of sockets.
I asked about 64bits because some say they need 64bit (more than 4GB, etc) for "larger scale apps" as 32bit won't do. Seems like 32bit is fine for what you're doing, but I was interested in more details.
@jonforums the larger scale applications we build are building automation systems: https://github.com/stakach/em_control
We're currently deploying our first big rollout (disastrous as we'd never scaled higher than 64 on windows) and we've got many more coming up. In fact this first 150 devices is only a small part of the rollout.
We also make a digital signage system that is entirely HTML5 (management + playback). Local deployments of that usually run on windows as we have to do powerpoint conversions and offloading to windows is more infrastructure + cost people don't want to see. Some of those deployments will be nearing 64 displays very soon.
@jonforums you looking at my telnet hack? (I stopped using that)
Anyway it's not quite ready for public release, I want to package it up somewhat like rails and have a project generator.
So that socket size seems limited to file descriptor max (2048).
If ruby did not use _open_osfhandle() for socket, socket size might not limited to 2048.
Hi Everyone, and sorry for the headache here, but I'm facing almost the same problem is my production server, I would really appreciate any help regarding this issue, I'm running my system with Ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] , at OS Ubuntu 12.04.1 LTS and em-http-request (1.0.3).
I have a ruby processes that consume msgs from a RabbitMQ queue using amqp gem, something like this :
require "bundler/setup"
require "amqp"
require 'eventmachine'
require 'em-http'
AMQP.start(:host => $AMQP_URL) do |connection|
@channel ||= AMQP::Channel.new(connection)
@queue ||= @channel.queue("results")
puts " [*] Waiting for messages. "
@queue.subscribe do |body|
http = EventMachine::HttpRequest.new(URL).post :body => body
http.callback { # do something }
http.errback { $LOG.error "[errorback] -> #{http.error}" }
end
end
Now the URL is slow, and the queue has so much messages ( > 30K ), I got this error in the log: [errorback] -> unable to create new socket: Too many open files
Any help would be highly appreciated since I've been trying all my time figuring out how to solve it but with no results at all.
@shirosaki I really appreciate your welling to help, but guide me more here since I'm not an expert with this, please check out what I've been trying to do :
@cubiic while interesting, this linux issue has nothing to do with rubyinstaller or ruby on windows.
Worse, the documentation for any fix will be buried in this thread and very difficult to for a linux user to find. That's a shame, and a waste of your and Shirosaki-san's efforts. The EM list, or the ruby-talk list (or even stackoverflow) are much better places to work/document the problem.
Sorry man , but I though the problem is relevant based on the return error i'm getting, if you don't feel so I can just close it, but I found "unable to create new socket: Too many open files" error relevant by googling it
It's related, but irrelevant on this project's issue list.
But don't miss my main point: I don't want the doco for a fix getting "buried" here. Switch the conversation (with an fyi link back here if you like) to a more linux visible place, like ruby-talk so we linux users can better help/benefit.
Activity
luislavena commentedon Mar 6, 2012
Can you be more specific? Which version of Ruby are you talking about? For 1.8.x we used to increase FD_SIZE to 256. Ruby 1.9 does not suffer from that.
https://github.com/oneclick/rubyinstaller/blob/master/config/ruby_installer.rb#L18-31
If you found that Ruby 1.9.2 or 1.9.3 suffered from that, perhaps your report is better suited to Ruby itself:
http://bugs.ruby-lang.org
Please confirm.
stakach commentedon Mar 6, 2012
Ruby 1.9.3 suffers from it, only for asynchronous IO and in any libraries that use functions Ruby core 1.9 now avoids such as select(2).
So the FD_SIZE should still be set and much higher than 256 for any serious async application.
stakach commentedon Mar 6, 2012
Basically libraries such as eventmachine require it to be set otherwise they are limited to 64 sockets which is pretty meaningless and considering I've been doing production deployments using EM and thin on windows it is pretty scary.
rdp commentedon Mar 6, 2012
for 1.8.x it's set to 256 isn't it?
jonforums commentedon Mar 6, 2012
@stakach:
any specific examples of "larger scale applications" on Windows other than your thin/EM deploys?
your "larger scale applications" don't require 64bit and aren't limited by our current 32bit build?
A bit off-topic, but I'm curious on if/how the following relate to what you're doing, and what you think of Greg's patch from 9 months ago?
http://bugs.ruby-lang.org/issues/4906
http://www.ruby-forum.com/topic/869239
stakach commentedon Mar 6, 2012
Yes, however 256 is way too low.
I've been hacking at Eventmachine for the last 2 days as I have application that is using ~150 sockets now and is intended to scale well beyond 1000 before the end of the year.
Right now it is 3am here and I'm configuring a Linux VM to NAT with the windows host so I don't hit the 64 limit. I would prefer not to be doing this again in a couple of months after I've reached the 256 limit...
There are 16383 ephemeral ports on windows (ie the probable max an application will ever use) can we use that?
stakach commentedon Mar 6, 2012
@jonforums
http://bugs.ruby-lang.org/issues/4906 === eventmachine/eventmachine@5f1b8d7
The 64 is the number of sockets, not 64bits.. I wish it was bits.
stakach commentedon Mar 6, 2012
Of course I'm not entirely sure of ruby internals, if there is a windows file descriptor wrapper for every socket (not just a ruby facade) then the limiting number of sockets would be Windows limit of 2048 file descriptors: http://msdn.microsoft.com/en-us/library/6e3b887c(v=vs.71).aspx
At least that limit is somewhat configurable at run time.
luislavena commentedon Mar 6, 2012
@stakach I can't find the issue reported by @rdp on Ruby-Core about
FD_SETSIZEI see the value of the request, however, please see this on MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms739169(v=vs.85).aspx
But, further reading:
We can up that numbre to 32767, which seems to be the maximum supported by
iMaxSocketsIf you agree, I'll change 1.9 recipe so next build will handle that.
jonforums commentedon Mar 6, 2012
@stakach hehe..yeh, I know the 64 number is the number of sockets.
I asked about 64bits because some say they need 64bit (more than 4GB, etc) for "larger scale apps" as 32bit won't do. Seems like 32bit is fine for what you're doing, but I was interested in more details.
stakach commentedon Mar 6, 2012
@jonforums the larger scale applications we build are building automation systems: https://github.com/stakach/em_control
We're currently deploying our first big rollout (disastrous as we'd never scaled higher than 64 on windows) and we've got many more coming up. In fact this first 150 devices is only a small part of the rollout.
We also make a digital signage system that is entirely HTML5 (management + playback). Local deployments of that usually run on windows as we have to do powerpoint conversions and offloading to windows is more infrastructure + cost people don't want to see. Some of those deployments will be nearing 64 displays very soon.
stakach commentedon Mar 6, 2012
@luislavena 32767 sounds great!
jonforums commentedon Mar 6, 2012
@stakach how very cool...cloning your repo...OT, could https://github.com/adoxa/ansicon be helpful for your colorization needs?
stakach commentedon Mar 6, 2012
@jonforums you looking at my telnet hack? (I stopped using that)
Anyway it's not quite ready for public release, I want to package it up somewhat like rails and have a project generator.
Otherwise everyone will have to clone the repo :)
jonforums commentedon Mar 6, 2012
yes
just scanned your repo, but would a single distributable .exe containing your Ruby stuff be a deployment option for you? FWIW, Luis has adopted a clone of exerb project https://github.com/luislavena/exerb-mingw and he and another guy have made some updates for 1.9.3. I haven't had time to play with the mods yet, but exerb/1.8.7 has worked well for https://github.com/vertiginous/pik
23 remaining items
stakach commentedon Aug 14, 2012
I have a feeling it is the file descriptor limit being hit.
Other wise someone would have had to have set WSAStartup's max sockets at 2045
Azolo commentedon Aug 15, 2012
Running the example I get this error on
client.rbat around 1000(+/-50) connections.Here is the
BasicSocketinitializationIt looks like
rb_update_max_fdis being called, but I have no idea what that actually does so it's just a hunch.shirosaki commentedon Aug 25, 2012
Ruby associates windows socket to a C run-time file descriptor by _open_osfhandle().
https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L3486
http://msdn.microsoft.com/en-us/library/bdts1c9x(v=vs.71).aspx
So that socket size seems limited to file descriptor max (2048).
If ruby did not use _open_osfhandle() for socket, socket size might not limited to 2048.
luislavena commentedon Aug 26, 2012
Thank you @shirosaki
So we conclude that having
FD_SETSIZEof 16K is pointless.Sometimes I wish Ruby did IO/socket implementation differently.
Anyhow, going to change the limit, again.
Thanks @stakach
cubiic commentedon Feb 8, 2013
Hi Everyone, and sorry for the headache here, but I'm facing almost the same problem is my production server, I would really appreciate any help regarding this issue, I'm running my system with Ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] , at OS Ubuntu 12.04.1 LTS and em-http-request (1.0.3).
I have a ruby processes that consume msgs from a RabbitMQ queue using amqp gem, something like this :
Now the URL is slow, and the queue has so much messages ( > 30K ), I got this error in the log:
[errorback] -> unable to create new socket: Too many open files
Any help would be highly appreciated since I've been trying all my time figuring out how to solve it but with no results at all.
Thanks in advance
shirosaki commentedon Feb 9, 2013
@cubiic have you tried to increase the open file descriptor maximum?
such as:
$ ulimit -n 100000http://serverfault.com/questions/235356/open-file-descriptor-limits-conf-setting-isnt-read-by-ulimit-even-when-pam-limi
cubiic commentedon Feb 9, 2013
@shirosaki I really appreciate your welling to help, but guide me more here since I'm not an expert with this, please check out what I've been trying to do :
https://gist.github.com/cubiic/f7c8b1ca3f56ac9fd73b
As you can see I've been trying to do that unsuccessfully,
Thanks in advance
jonforums commentedon Feb 9, 2013
@cubiic while interesting, this linux issue has nothing to do with rubyinstaller or ruby on windows.
Worse, the documentation for any fix will be buried in this thread and very difficult to for a linux user to find. That's a shame, and a waste of your and Shirosaki-san's efforts. The EM list, or the ruby-talk list (or even stackoverflow) are much better places to work/document the problem.
cubiic commentedon Feb 9, 2013
Sorry man , but I though the problem is relevant based on the return error i'm getting, if you don't feel so I can just close it, but I found "unable to create new socket: Too many open files" error relevant by googling it
jonforums commentedon Feb 9, 2013
It's related, but irrelevant on this project's issue list.
But don't miss my main point: I don't want the doco for a fix getting "buried" here. Switch the conversation (with an fyi link back here if you like) to a more linux visible place, like ruby-talk so we linux users can better help/benefit.
shirosaki commentedon Feb 10, 2013
@cubiic
$ ulimit -S -n 100000would work for non-root user.http://askubuntu.com/questions/162229/how-do-i-increase-the-open-files-limit-for-a-non-root-user
If more guide is needed, please switch the place as Jon stated.
cubiic commentedon Feb 10, 2013
Thanks a lot for the help here,