Question 4 of 11 · PYQ 2025 · 6 marks
Open in ChatGPTDescribe the process and challenges of implementing Attribute-Based Naming.
Introduction
Flat and structured naming both assume the client knows the name. Attribute-based naming starts from the opposite end: the client knows only what the entity is: its properties: and asks a directory to find it.
The process
- Register: an entity publishes its attributes (type, location, capacity, status) to a directory service.
- Query: a client sends a predicate over those attributes: "a colour printer, floor 3, idle".
- Search: the directory returns the set of entities whose attributes satisfy the predicate.
- Select and resolve: the client picks one and resolves its name to an address, or the directory returns the address directly.
- Update: entries expire or are refreshed by heartbeats, so a dead entity stops being found.
The directory is usually a distributed database with an index on each attribute, and queries may be combined with ranges, comparisons and boolean operators.
Challenges
- Attribute schema. Who decides that the attribute is called
printerColourand notcolour? Without a shared schema, two services describe the same thing differently and the search misses it. - Scale of the index. Every attribute needs an index that can be searched and updated at the rate of heartbeats; a global directory is a bottleneck.
- Naming collisions. Attributes identify a set, not one object, so results must be ranked or filtered by the client.
- Staleness. Registrations go stale when a node crashes; the directory needs leases, heartbeat expiry and a consistent view of what is alive.
- Security. Anyone can publish attributes, so a client needs to know which entries it can trust: spoofing a service entry is an attack.
- Query cost. A broad predicate can return thousands of entries, so results must be paginated and ranked.
Example
Service discovery in a microservice cluster: a service registers {name: payment, version: 2, zone: ap-south-1, status: healthy} in a registry such as Consul. A client asks for name=payment AND version>=2 AND status=healthy and gets the healthy instances, instead of holding a fixed list of addresses.
Conclusion
Attribute-based naming decouples what a client wants from where it is, and pays for that with a schema to agree on, an index to maintain, and leases to expire. It is the naming scheme of service discovery, which is exactly the problem it solves best.