Reputation: 41
Play! touts its asynchronous HTTP handling feature, though it is not very clear to me what else are truly async (non-blocking and without thread switching.) In the asynchronous examples I read, like the one below taken from the Play! Framework Cookbook:
public static void generateInvoice(Long orderId) { Order order = Order.findById(orderId); // #a InputStream is = await(new OrderAsPdfJob(order).now()); // #b renderBinary(is); }
They focuses on the long/expensive "business logic" step at #b, but my concern is at the DB calls at #a. In fact, majority of the controller methods in many apps will just try to do multiple CRUD to DB, like:
public static void generateInvoice(Long orderId) { Order order = Order.findById(orderId); // #a render(order); }
I'm particularly concerned about the claim of using "small number of threads" when serving this DB access pattern.
So the questions are
Upvotes: 4
Views: 589
Reputation: 3624
I'm not convinced Play's async feature is worthwhile, given how much it complicates the code and testing. Maybe if you need to handle thousands of requests per second on a single machine while calling slow services.
Upvotes: 1