This is a general question but for arguments sake you may and assume we have a collection of processes communicating via a combination of AMQP and HTTP. There are two specific cases to consider.
The easy one:
- Q) If A sends a message to B how does B identify the location of A to send a reply.
- A) A must tell B where to send it somehow (exchange for AMQP, URL for http)
The harder ones:
- Q) How does a monitoring process send a message to A (where something else has prompted this desire - e.g. B says A sent me a bad request)
Q) How does a monitoring process kill or restart A.
This could be something like kill a host+pid or a pod or a pod+container
(see for example kubernetes restart container within pod)
You might wish to restart an entire service or some subset of the processes that are providing that service.
Now you can assign a UUID yourself but you need a table to map it. This may have multiple columns but sometimes a single URI (or URI like thing) is useful for example as a "originated from/reply to" address.
Another way to view this question. In the old days it was easy to identify a process.
A hostname (or IP address) + a PID was sufficient
Then came virtualisation the IP address identifies the virtual network port assigned to the VM and the PID identifies the process within it. A hostname and IP address are still sufficient. Sometimes you need the vhost as well (though I was never clear why)
Now adding containers to the mix a container doesn't necessarily have a IP address of its own. A host+pid can identify the container But you might not know the host if you are running kubernetes or docker swarm.
Now we don't talk about processes so much anymore as about services. It used to be enough to identify a service using a hostname (or IP address) and a port (YMMV - Can an IP address and a port number together uniquely identify a process ID?).
Now we have load balancers and other tricks (e.g. caching proxies) to redirect messages to something else that actually provides a service.
A service might be provided by a container or a pod containing several containers in which case you may want to address the pod or the container. See for example kubernetes restart container within pod It looks like container names are unique per docker instance but not beyond that.
So there a few different ways you might want to address a message. Is there a good standard way of doing this?
To my mind the obvious thing to use is a URI (but I could be wrong). Are there recommended URI forms to handle all possible cases? (obviously we have procotocl://host:port/ for the easy cases)
After some consideration I believe host+pid is still sufficient (but not necessarily the best way) to identify a process providing you are mindful of the following:
whose PID you mean could be ambiguous. It could be the PID of the container's namespace or the host.
If you are referring to the process from outside the container you need to use the PID of the host not the PID as it appears inside the container as this is in a separate process namespace. See for example the-curious-case-of-pid-namespaces
The container may evem be able to identify the host and PID itself (after all it is supposed to be a sandbox)
IP addresses will be relative to the internal network (as normal)
hostnames will go via DNS lookup (as normal)
Now a URI refers to a port not a PID so a URI is not appropriate here. PID@HOST is probably a sensible notation but beware confusion with user@host.
In addition to container and pod Ids there are other more convenient ways to identify a processing resource such as stateful sets