Why did you do this as a batch job? Do you run batch jobs instead of resizing them when a user uploads the pictures? Thanks for sharing.
Batch Processing Millions and Millions of Images
11–20 of 23 posts
Re: Batch Processing Millions and Millions of Images
#12Did you investigate resizing them on the fly with some kind of caching layer? As one of the posters notes, it seems likely that a lot of those images will be very rarely seen, if ever.
Re: Batch Processing Millions and Millions of Images
#13Re: Batch Processing Millions and Millions of Images
#14The author spends time tuning the number of workers and the number of OpenMP processes per worker for GraphicsMagick on his 16-core machines. Isn't this type of tuning a waste of time? Even using just two cores instead of one seems to introduce inefficiency. Wouldn't he have been better off just using 16 workers, each compiled without OpenMP so that it would run serially (and more efficiently)?
Re: Batch Processing Millions and Millions of Images
#15The problem of resizing all these images is an "embarrassingly parallel" one, right? You don't care about how fast any individual image is resized, only how fast they're resized in aggregate, and each image is a nice small chunk of work. The author spends time tuning the number of workers and the number of OpenMP processes per worker for GraphicsMagick on his 16-core machines. Isn't this type of tuning a waste of tim…
This is the sort of stupid batch task that can be done with a shell-script using all the machines in the office after hours. Cut out the middle ware, cut down the threads and fancy IPC, and hunker down with good ole minimal number of processes on a bunch of machines.
Heck, they might even see a big win if they use a different "server" memory management algorithm that's more tailored to batch, not-so-responsive applications.
Re: Batch Processing Millions and Millions of Images
#16This looks like a problem for which I could write the code in 15 minutes. Assuming Markham's Rule of Estimating (double the number and go to then next larger unit), that's about 30 hours of work.
This is a problem just begging for a functional solution. If you've got a language that already has a bunch of libraries, like .NET, you just wire it up, pipeline it, and send it out to as many workers as you want. The image tweaking, worker nitpicking stuff just isn't worth the time. If you're doing millions of everything, then I'm sure you've already got some broker parallelization thing going on. Shouldn't need to redo that every time. If you want to be truly anal, do some tests to determine the fastest way to compress. But aside from that, it's all big old hunks of immutable data splaying out into the universe, running on as many cores as you need.
I probably missed something. These things always look simpler from the outside.
Re: Batch Processing Millions and Millions of Images
#17"In fact, the research phase of this project took longer than the batch processing itself. That was clearly time well spent."
I'm not so sure about this. A sufficiently parallelized but otherwise unresearched script could have been created in a fraction of the time. So you would just generate the correct thumbnails on new uploads and then let the batch job run for, say, two weeks. That naive approach will take you around a days worth of development time.
The time you gained by doing it the naive way you then put into the rewrite of that legacy component that prevented you from on-the-fly generating the images.
What you have done here is, IMHO, wasted time in a legacy solution and you wasted hardware resources for storage of the additional pictures of which probably only a minority will actually be seen anyways.
Don't get me wrong: I'm sure you had a lot of fun and there's little more exciting things than seeing your code perform magnitudes quicker than the initial approach. But in the context of your quote, I have to disagree.
Unless there's more background you didn't tell us about.
Re: Batch Processing Millions and Millions of Images
#18The problem of resizing all these images is an "embarrassingly parallel" one, right? You don't care about how fast any individual image is resized, only how fast they're resized in aggregate, and each image is a nice small chunk of work. The author spends time tuning the number of workers and the number of OpenMP processes per worker for GraphicsMagick on his 16-core machines. Isn't this type of tuning a waste of tim…
You really nailed it. Yes, yes and yes! This is the sort of stupid batch task that can be done with a shell-script using all the machines in the office after hours. Cut out the middle ware, cut down the threads and fancy IPC, and hunker down with good ole minimal number of processes on a bunch of machines. Heck, they might even see a big win if they use a different "server" memory management algorithm that's more tai…
$ cat filelist.txt|xargs -n 1000 -P 16 ./myconvertprog
I do "batch" compression like this all the time.Re: Batch Processing Millions and Millions of Images
#19This system doesn't scale out without ad-hoc partitioning. I think Etsy's approach here should have been informed by the New York Times' project a few years ago. They converted 4 TB of scanned tiffs (their article archive) into PDFs on a hadoop cluster running on ec2 and s3. Parallelizing the process across hardware nodes is the scale free way to do this, exactly what hadoop was intended for.
All that said, I know there are smart folks at Etsy. I'll give 'em the benefit of the doubt; there may be a good reason not to go that route but this write up didn't make that clear.
Re: Batch Processing Millions and Millions of Images
#20Hate to be the Monday morning quarterback but hey, it's Saturday morning and I'm stuck in a Starbucks in Benicia. So, this is a nice walk through the optimization process but it is a fundamentally unscalable system. When the workload triples next year, does it make sense to scale up the hardware? (No) This system doesn't scale out without ad-hoc partitioning. I think Etsy's approach here should have been informed by…