Search code examples
lagom

Deploy a dynamic Service Gateway for Lagom in production


I have developed a set of Lagom microservices. The development environment provides with default Service Gateway and Service Locator.

In a production environment I would like my services to:

  • register to a service registry
  • be available to a web app through a service locator that uses this registry

What should I use as Service Registry / Service Locator / Service Gateway ?

A simple NGINX would be a reasonable service gateway but it implies a very static configuration based on redirect rules (no actual registration).

I cannot find any code sample on this subject and the documentation is very poor (it describes well development tools but doesn't help when it comes to actual production).


Solution

  • The documentation on that area is vague on purpose because the ecosystem is very vast and changes fast.

    You could, for example, use Consul or ZooKeeper to keep track of the instances that are runnning for each service and where they are running (where means IP:PORT). Then you would need to use a Consul-based or a ZooKeeper-based Service Locator instance. The preferred target deployment environment these days is Kubernetes (in any of its flavors) so the service location is based on DNS-SRV lookups on the DNS server provided by k8s. The registration step happens automatically in a k8s setup for each pod so you won't need to care for that.

    Then, the reverse proxy on the edge capable of directing each request to the appropriate process is a plain-old HTTP proxy that can check your service location (or cache the service location information). These days the recommendation is configuring an Ingress/Route (for k8s or OpenShift) edge proxy for each of your lagom services.

    See the guide on Deploying a Lagom application to Openshift for a thorough explanation.