Hello guys,
(I erased the template since this is not a bug report, say me if I still have to use it)
I'm using Ktor for quite some time now for a heavy project in my company (in production use).
I would like to switch all our project to a micro-service pattern which could help us build more easily new services, better manage services and maintains codes.
I thought to build each services with a "router builder" function called in a main Ktor application where a microservice is a git repository building a jar.
Not sure it's the best idea, and not sure this well explained.
Do you have some ideas how I could achieve this using Ktor ?
Thanks a lot, :)
So I am right that the idea is to dynamically plug routes/modules from an external service providing jars ?
It is rather: dynamically plug routes/modules (here, named micro-services) from an external jar
Does it mean that you need to unload/reload modules as well? It sounds like OSGi or servlet container. This is not yet supported by ktor
Yep, OSGi and servlet sounds good, sorry I鈥檓 quite new in the Java world :)
Ok, I will try to find some good alternative usine Ktor
You could have each microservice be a separate running instance, managed by a load balancer (which would also handle routing for you). That way you can have autoscaling specific to each microservice and other neat features which make microservices as useful as they are.
@Bluexin Yeah, I'm actually working like that using AWS. I've dockerized each micro-service using a JAR file and with a kind of NGINX in front of them.
Sorry I can close that issue btw :)
@scorsi Would you mind elaborating a bit? Would love to hear more about the design, architecture, deployment practices etc. you ended up following with ktor + microservice approach 馃榿
Hello @AdityaAnand1 馃憢,
@scorsi Would you mind elaborating a bit? Would love to hear more about the design, architecture, deployment practices etc. you ended up following with ktor + microservice approach 馃榿
For example:
I have a service-users with CRUD route on / (POST, PUT, DELETE and GET plus GET on /{:id}). And a second service service-notes with the same routes on /.
Each services are a standalone executable running Ktor _(or any frameworks/languages you want)_, each services available on service-users = localhost:8080 and service-notes = localhost:8081, ... or each services in differents host like service-users = users.services.api.example.com and service-notes = notes.services.api.example.com.
In a Nginx on api.example.com you use a reverse proxy to route all requests on /users to the corresponding url localhost:8080 or users.services.api.example.com and do the same for /notes for the notes service. Don't forget to rewrite the url to change /notes/do/something to /do/something on the service http call. So when you request api.example.com/users, the request will be reversed-proxy to users.services.api.example.com/ or internally to localhost:8080/.
Then you can dockerize each services using AWS Fargate, AWS ECS or AWS EKS to run your docker images, a simple AWS ELB or a AWS EC2 with Nginx installed to route the traffic to the correct docker, AWS ECR to register version and reuse your docker containers and finally AWS CodePipeline, AWS CodeBuild and AWS CodeDeploy for some magic CI/CD.