I know that Zed has made mention of the fact that using RMagick with mongrel and rails is a bad thing. I''m currently using FlexImage (which in turn uses RMagick) on my application and really haven''t had too many problems. We get a restart for memory usage every 8-10 hours on one mongrel of twelve running, but I''m not sure if that''s an RMagick issue. Either way, I''d like to make my system better if I can. Right now I''ve got controllers that are using both send_data (sending image stored in the db, using RMagick to crop/resize before sending) and send_file (sending a static image on the site that needs to be sent inline). Image upload is being handled by FlexImage, which will save the image to the DB, resizing it to 640x480 before saving if it''s too big. My question is, what then is the preferred method of doing image manipulation while running mongrel? Convert FlexImage to use mini-magick? Create a custom system to offload the image processing to another process? If someone can provide some insight or examples, it would be appreciated.
On Fri, 15 Dec 2006 11:14:20 -0600 "Joey Geiger" <jgeiger at gmail.com> wrote:> I know that Zed has made mention of the fact that using RMagick with > mongrel and rails is a bad thing. I''m currently using FlexImage (which > in turn uses RMagick) on my application and really haven''t had too > many problems. We get a restart for memory usage every 8-10 hours on > one mongrel of twelve running, but I''m not sure if that''s an RMagick > issue. Either way, I''d like to make my system better if I can. > > Right now I''ve got controllers that are using both send_data (sending > image stored in the db, using RMagick to crop/resize before sending) > and send_file (sending a static image on the site that needs to be > sent inline). Image upload is being handled by FlexImage, which will > save the image to the DB, resizing it to 640x480 before saving if it''s > too big. > > My question is, what then is the preferred method of doing image > manipulation while running mongrel? > Convert FlexImage to use mini-magick? > Create a custom system to offload the image processing to another > process? > > If someone can provide some insight or examples, it would beI work on a <shall not be named here> large Web site devoted to handling large numbers of photographic imagery. Although our site is not running in Ruby, yet, we have worked through a number of approaches to handling this, but only one has the desired properties we need, which is automatic recovery and minimal impact to running code on failure: exec out another process to do image manipulation. If you''re doing something small, feel free to use RMagick+death+recovery if you want, but exec-ing out really is the way to go. Jim -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20061215/f31b35c1/attachment.bin
Just to chime in - we are using RMagick with Gruff on mongrel/apache combo without any memory leaks or restart problems. Our cluster happily runs for weeks at a time, before we restart it (usual because of new code released). I am also curious to know what specific problems are reported related to RMagick. Thanks Konstantin On Dec 15, 2006, at 9:14 AM, Joey Geiger wrote:> I know that Zed has made mention of the fact that using RMagick with > mongrel and rails is a bad thing. I''m currently using FlexImage (which > in turn uses RMagick) on my application and really haven''t had too > many problems. We get a restart for memory usage every 8-10 hours on > one mongrel of twelve running, but I''m not sure if that''s an RMagick > issue. Either way, I''d like to make my system better if I can. > > Right now I''ve got controllers that are using both send_data (sending > image stored in the db, using RMagick to crop/resize before sending) > and send_file (sending a static image on the site that needs to be > sent inline). Image upload is being handled by FlexImage, which will > save the image to the DB, resizing it to 640x480 before saving if it''s > too big. > > My question is, what then is the preferred method of doing image > manipulation while running mongrel? > Convert FlexImage to use mini-magick? > Create a custom system to offload the image processing to another > process? > > If someone can provide some insight or examples, it would be > appreciated. > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users
> Although our site is > not running in Ruby, yet, we have worked through a number of > approaches > to handling this, but only one has the desired properties we need, > which is automatic recovery and minimal impact to running code on > failure: exec out another process to do image manipulation.I must admit that we do the same thing at 37signals. But actually not because of memory leaks, but because we found it easier to do: def thumbnail(temp, target) system "convert #{escape(temp)} -resize 48x48! #{escape(target)}" end Rather than to get the full RMagick machinery cooking. -- David Heinemeier Hansson http://www.37signals.com -- Basecamp, Campfire, Backpack, Getting Real http://www.rubyonrails.com -- Web-application framework http://www.loudthinking.com -- Broadcasting Brain -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 1940 bytes Desc: not available Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20061215/045b55d4/attachment-0001.bin
On 12/15/06, David Heinemeier Hansson <david at loudthinking.com> wrote:> > Although our site is > > not running in Ruby, yet, we have worked through a number of > > approaches > > to handling this, but only one has the desired properties we need, > > which is automatic recovery and minimal impact to running code on > > failure: exec out another process to do image manipulation. > > I must admit that we do the same thing at 37signals. But actually not > because of memory leaks, but because we found it easier to do: > > def thumbnail(temp, target) > system "convert #{escape(temp)} -resize 48x48! #{escape(target)}" > end > > Rather than to get the full RMagick machinery cooking.There''s also minimagick, which is a shell around imagemagick commands. Probably easier if you want to do more complex operations on your images. Oh, and ImageScience, which uses FreeImage and a light inline ruby wrapper. http://seattlerb.rubyforge.org/ImageScience.html -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com
> I know that Zed has made mention of the fact that using RMagick with > mongrel and rails is a bad thing. I''m currently using FlexImage (which > in turn uses RMagick) on my application and really haven''t had too > many problems. We get a restart for memory usage every 8-10 hours on > one mongrel of twelve running, but I''m not sure if that''s an RMagick > issue. Either way, I''d like to make my system better if I can. > > Right now I''ve got controllers that are using both send_data (sending > image stored in the db, using RMagick to crop/resize before sending) > and send_file (sending a static image on the site that needs to be > sent inline). Image upload is being handled by FlexImage, which will > save the image to the DB, resizing it to 640x480 before saving if it''s > too big. > > My question is, what then is the preferred method of doing image > manipulation while running mongrel? > Convert FlexImage to use mini-magick? > Create a custom system to offload the image processing to another process? > > If someone can provide some insight or examples, it would be appreciated.Just to add to what others have said there is also the GD2 library and if you''re willing to shell out, netpbm. Although I would imagine GD2 has the same potential for memory leaks as ImageMagick if I understand the issue correctly (that is ruby not knowing about memory allocated by the extension). We use rmagick now, but don''t upload that many images (admin interface only). My last job (not Rails, but that doesn''t matter) we shelled out to netpbm for a couple of reasons -- we were dealing with a lot of arcane formats (PCX with specific header formats) and because I''d run some tests converting/scaling images using GD, ImageMagick, and netpbm and netpbm seemed to do the best job and delivery the smallest file. Now... that was about six years ago so things may certainly have changed. -philip
Just as an update, I went and did some conversion and gutted FlexImage, removing everything but the crop and resize actions, which are the only ones I was using anyway. Removed RMagick and rewrote stuff to use mini_magick. Everything seems to be working OK except an issue with Tempfile on windows. It seems when I run my code on Windows, the Tempfile is created and deleted before I''m done with it. I found some code online that lets me persist tempfiles, which is fine for me in Win32, since I''m only using it for development. I did a bit of testing, and I was able to get the memory use of a single mongrel to max out at about 56mb. Depending on what I was doing with some images, it spiked to 80mb, but dropped back down to 56, which is acceptable. This was on mongrel 1.0rc1 btw. On 12/15/06, Rick Olson <technoweenie at gmail.com> wrote:> On 12/15/06, David Heinemeier Hansson <david at loudthinking.com> wrote: > > > Although our site is > > > not running in Ruby, yet, we have worked through a number of > > > approaches > > > to handling this, but only one has the desired properties we need, > > > which is automatic recovery and minimal impact to running code on > > > failure: exec out another process to do image manipulation. > > > > I must admit that we do the same thing at 37signals. But actually not > > because of memory leaks, but because we found it easier to do: > > > > def thumbnail(temp, target) > > system "convert #{escape(temp)} -resize 48x48! #{escape(target)}" > > end > > > > Rather than to get the full RMagick machinery cooking. > > There''s also minimagick, which is a shell around imagemagick commands. > Probably easier if you want to do more complex operations on your > images. > > Oh, and ImageScience, which uses FreeImage and a light inline ruby > wrapper. http://seattlerb.rubyforge.org/ImageScience.html > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >