4.08.2015

Building Microservices with Spring Boot and Apache Thrift. Part 3. Asynchronous services

Have you thought about making your server asynchronous? How much time your server spent in database calls? External service calls? New shiny database library now supports asynchronous queries? It's time to processing requests in an async manner! And it's super easy with Facebook Swift!


Hardest part

How do you think, how much changes you need to do to make your Swift service asynchronous? Do you afraid of it? You already scheduled a week for this refactoring? Oh, that's nice:)

Now it's time to update your service implementation. Are you ready?

Hope you noticed this ScheduledExecutorService and 2 seconds delay. You shouldn't use it in your real application, this is just for example of promises (unless you want to simulate work for future optimizations like this guy: http://thedailywtf.com/articles/The-Speedup-Loop )

That's it, now your server is asynchronous. There is more - your clients can consume your service like before in non-async manner. How cool is that?

Full source code at GitHub: https://github.com/bsideup/spring-boot-swift/tree/async

Previous parts:

0 comments:

Post a Comment