News for hackers. Stuff that matters.
Re:Speeding Up Rendering Rails Pages with render_async by ewalk153 on Thursday June 08, 2017 @09:48AM (#14514141)
I would use a technique like this sparingly. It looks to be the "web request" equivalent of an n+1 query.

Imagine you have a table of results and each one is taking time to render. You add this for each row, but you only test it locally with a few rows. In production, maybe that table has hundreds of rows.

You've just DOSed your server.

Re:Speeding Up Rendering Rails Pages with render_async by schnika on Thursday June 08, 2017 @10:14AM (#14514289)
Well, as with everything:

Before using a library blindly 1. Ask yourself which problem you want to solve 2. Educate yourself 3. Does the library solve you problem 4. Use with caution 5. Learn from you mistakes :D

Re:Speeding Up Rendering Rails Pages with render_async by ewalk153 on Thursday June 08, 2017 @10:23AM (#14514354)
Those are great steps to follow for yourself and to reach new members of your team :)

I still hold that sparing use is important.

The overhead for steps before your controller action method can often be a significant portion of the overall response time.

Re:Speeding Up Rendering Rails Pages with render_async by nateberkopec on Thursday June 08, 2017 @11:12AM (#14514726)
It does seem somewhat dangerous to use on a collection. But for scenarios like a few parts of the page which depend on the logged-in-user, it seems pretty safe.
Re:Speeding Up Rendering Rails Pages with render_async by smileysteve on Thursday June 08, 2017 @10:39AM (#14514470)
In a way that scales horizontally; run all of those web workers!
Re:Speeding Up Rendering Rails Pages with render_async by Colex on Thursday June 08, 2017 @10:11AM (#14514266)
Browsers usually limit the number of requests to a certain domain (around 8 requests if I'm not mistaken, but it may vary). So I don't think it'd be the cause of a self inflicted DOS. Also, every solution must be used carefully where it makes sense, if it doesn't make sense, then a different solutions must be thought of.
Re:Speeding Up Rendering Rails Pages with render_async by mnarayan01 on Thursday June 08, 2017 @10:28AM (#14514382)
True, though note that the limit is on active requests on the browser end (obviously). If your subrequests are "heavy" and the user refreshes a bunch, you're now going to have 6x (or 8x or whatever the limit is on their browser) the number of "zombie" requests still being processed on your server.
Re:Speeding Up Rendering Rails Pages with render_async by ewalk153 on Thursday June 08, 2017 @10:27AM (#14514376)
It takes the total cost to a server to render a page and multiplies it.

Under low load, it could make it faster for one user.

Under higher load, each initial page request will be more expensive and therefore will result in exhausted resources sooner.

Re:Speeding Up Rendering Rails Pages with render_async by nateberkopec on Thursday June 08, 2017 @11:07AM (#14514679)
Only over an HTTP/1 connection. Chrome and FF limit it to 6.
Re:Speeding Up Rendering Rails Pages with render_async by mtarnovan on Thursday June 08, 2017 @11:14AM (#14514740)
That's incorrect. Browsers limit request to 8 req/domain at the same time.
Re:Speeding Up Rendering Rails Pages with render_async by mtarnovan on Saturday June 10, 2017 @03:25PM (#14528774)
Don't know why I was downvoted. For reference: https://en.wikipedia.org/wiki/HTTP_persistent_connection#Use...

The limit applies only to persistent connections.