allegro / marathon-consul

Integrates Marathon apps with Consul service discovery.
Apache License 2.0
191 stars 33 forks source link

Use app definition for task in same version. #170

Open janisz opened 7 years ago

janisz commented 7 years ago

With https://github.com/allegro/marathon-consul/pull/145 and https://github.com/allegro/marathon-consul/issues/164 we put a plaster on Marathon app task differences. We should obtain app definition for task in version defined in task. We can use /v2/apps/{app_id}/versions/{version} endpoint to get this information. What's more we can cache app definitions and to reduce calls to marathon. Only drawback of this solution is versions could not be available since it could be configured to keep last n entries. We need to think what we should do in that circumstances.

janisz commented 7 years ago

App definition for given version is immutable so we can cache it. This will reduce Marathon queries but will increase memory usage (one app definition JSON takes approx 2.36K). We need to handle applications that was not changed but only scaled. This means we need to persist App Definitions. Cache entry could be evicted if it's not used within sync interval. We could use https://github.com/golang/groupcache but then we need to think about data peristency if one or more instance goes down (e.g. version update).