Simulating microservices using F# and Suave.io
I have this small hobby project called Overseer. It is a tool used to debug and troubleshoot microservices. I was planning to use it in production, but because that is the only prototype. I decided to use it with simulated services. This way it will be a lot easier to create many different ‘test’ scenarios.
The current solution for spawning those ‘tests services’ is implemented in Suave.io and F#. Why these technologies? I just like F# and Suave.io seems like a nice decent framework. Full code If you can, please review this code. I am not a F# expert and would love to learn how to make it better.
Test service graph definition
I want to iterate fast and create different networks of services. I need a simple way of defining the structure of the network. At the moment, I am using an array of tuples with a service name and collection of all the services it depends on. It looks like this.
This array of tuples is changed to Suave web ‘servers’ with one endpoint.
The result is a list of Tasks running suave exposing one simple endpoint.
Endpoint list
To create a list of the endpoints, I am using fold function with an accumulator to increment port. Fold is a function that I tend to overuse too much. But in this case, it feels ok. Is there any other way to iterate through something with a maintnance of external state?
Suave config
It was a bit tricky as the documentation is not that good. After many try and errors and SO searching, I was able to create simple endpoints. All it does is returning JSON metadata describing ‘server’ (status, dependencies).
Result
All the dependencies, links to them, ports are here. This data is then used to create a graph app id d3.js, example.
This is still in the making. D3.js is really powerful but quite tricky to use. I am mostly experimenting and there are a lot of ‘wow’ moments. Kind of feels like winapi programming a long time ago.
The first test was done with 11 services and it ‘works’. Wonder how it will cope with 100+ services. That is a topic for a different blog post.