Posts

Showing posts from 2018

Polling vs WebSockets - Part 2 - Stress Testing

Image
In my previous blog post, I discussed the efficiency of polling compared to WebSockets  for a web application.  Using these two different implementations and performance tests, I decided it would be interesting to perform some stress testing to see which solution can handle the most load. All code on github here .  For details of the original problem and performance tests, see here Let's increase the threads until it fails Even with a low number of threads, occasionally I would encounter errors - most likely soon after the server had started in its new Docker container.  Therefore I decided to run each scenario three times and display all results. Scenario - 40 Threads Job duration 0-10 seconds 40 Threads/Users - Instant ramp up Each Thread creating 10 jobs Polling interval of 500ms Timeout: 11 seconds Results - Some Errors from WebSocket implementation Run 1 Polling - 0 errors WebSockets - 0 errors Run 2 Polling - 0 errors Web...

Efficiency of Polling vs WebSockets

Image
A web application I maintain uses polling from the front end to check if a long running task is complete. A colleague suggested that WebScokets would be a far better alternative in terms of performance and user experience. Having never used WebSockets before and keen to see just how much better it could be, I decided to compare the two approaches to a contrived but similar problem side by side. All code on github here . The problem My hypothetical problem involves jobs. Each job consists of: a unique id a boolean named complete A job is created by a client of the application and after a random duration the job completes (i.e. complete = true). The client needs to know as soon as possible once a job is complete.  This can be achieved by the client polling a job's status repeatedly until complete, or receiving a "job completion" event once finished. For both solutions I decided to use Kotlin and the Dropwizard framework. Both of which I...

ASCII Art Mazes and Playing with Kotlin

I decided to play around with Kotlin for fun on a home project that interested me.  At many points during the development I was thankful that I was using Kotlin and not Java, here's a few notes that explain why.  All the code for this page can be found here:  https://github.com/phillbarber/kotlin-maze-demo The Problem Given a simple 2D maze inputted in an "ASCII art" format, write some kotlin code that will plot a route from the Start to Finish. In other words, given this... ############################################ # # # # # # # # # # # # # # # # # # # # # # # F # # # # # # # # ...