开发者

Is there any way I could improve performance here?

开发者 https://www.devze.com 2023-03-15 16:13 出处:网络
First off, if you read through my question description and feel that I have not provided enough information, please let me know and inform me on what would be helpful in providing:

First off, if you read through my question description and feel that I have not provided enough information, please let me know and inform me on what would be helpful in providing:

I'm using PhantomJS, a "headless" Webkit engine, to dynamically generate rather large images of ten websites within each web request. I'm currently using Ruby threads to run these processes in parallel (each "process" is the generation of an image for a single website, and so I have ten threads running for each web request). However, even when doing this, a single request (containing the ten threads running in parallel) tends to take up to two minutes on my local Webrick server, which is simply unacceptable to ask the user to bear.

I'm definitely going to be moving these processes to a background task and then update the page with AJAX with the images so as not to tie up the web request and make the user experience better. However, I do not think that switching from threads to a background task (I'm thinking of using Resque) will actually shorten the time it takes to gen开发者_JAVA技巧erate and display the images (I believe Resque can run its tasks in parallel so that I will not need threads?).

So my question is how can I generate and display these images more quickly? I'd appreciate any advice, ranging from what servers or environments to run this on to what tools to use. I'm not tied to anything I'm currently using.


Not enough information to make any solid suggestions, but:

I'm currently using Ruby threads to run these processes in parallel.

What do you call a "process" here? The retrieval of ten web sites together, or the retrieval of each of those ten? If you do the ten requests in parallel, that would be faster than the groups of ten being run in parallel, but those ten requests being run serially within each group.

0

精彩评论

暂无评论...
验证码 换一张
取 消