--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
What you're describing is potentially a bottleneck, but how much of one would depend on your system.I'd say the fileExistsSync check might be slow on machines that have to get a lot of stuff off a remote server. At least you're not using readAsStringSync. Test it both ways, see what works.
Even if you were to have handlers be a List<Future<bool>>, then your second or third handler would have to wait for all the previous handlers to fail before examining the request.
On 21 Sep 2014 21:15, "Arron Washington" <l33...@gmail.com> wrote:
>
> In the Ruby on Rails world the convention is generally to let multi-threaded optimized web server (Apache, nginx) serve all your static content and let your app web server handle the rest via a reverse proxy. Then you add on a CDN like Cloudfront on top of that as your asset host, letting your Apache / nginx setup act as the "origin server" for Cloudfront.
Sometimes a CDN is an unnecessary complication (this is only a toy app to learn some Dart, and CDNs can make automated deployments more involved), but also, static content isn't the only thing you might hit disk for. If you have server-side view templates, they're going to come from local storage. The question was more about the impact of stalling a single threaded web server for IO (and since Shelf does it, I wanted to know if I'd overestimated the impact).
--
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
Well, loading a template is generally a few file system calls, versus say loading many many assets like stylesheets, vendored javascript files, images and sprites, etc. I guess its less of an issue if you can compile everything down into one large spritesheet, one large javascript file, and one large stylesheet.I see what you're saying though.By the way, you should check out Cloudfront's origin server feature if you consider CDN deployments hard. They basically proxy a single request to your server to fetch an image when a client requests it from them, then serve it up from their edge locations:http://myapp.cloudfront.com/homepage_image.png --> http://myapp.com/homepage_image.png (and then never again... until 12 hours pass, anyway).If you hash your assets on deploy you never have to manually invalidate the CDN yourself, since the filename will always change.
The short answer is 'it depends'.Reading files synchronously will block the main Dart thread - something you normally would prefer to avoid. However, when you use non-blocking IO calls, they are offloaded to other threads, and that will introduce a minor overhead. That overhead have to be taken into consideration, as well as the estimated time the call will block.
Kevin Moore, do you have any thoughts on this? Did you code shelf_static that way mainly for convenience or was it some other reasoning?
A
In my benchmarks, that's what I saw. At low throughout the requests were faster but at high throughput, they were slower (presumably because they got queued up while all the requests in front of them stalled for IO).
Didn't make it any easier to decide which way to do it through :(
Did you measure throughput? I can imagine it might be faster for a single request but if it blocks the event loop longer it might result in being able to serve less requests concurrently
--
In something like ASP.NET, I wouldn't think twice about a blocking call in a request because it's threaded; however in Dart, it seems like it would be a bottleneck if every request is blocking every other request for the duration of IO hits like this.
In something like ASP.NET, I wouldn't think twice about a blocking call in a request because it's threaded; however in Dart, it seems like it would be a bottleneck if every request is blocking every other request for the duration of IO hits like this.Don't want to go too off topic, but even in asp.net you can exhaust the thread pool if you're doing blocking IO (assuming moderate volume). Of course, you can leverage async/await and all the non-blocking methods that .net supports to get the best of both worlds.