---
title: "Default Servants"
url: https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants
language: python
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Default Servants

Programming language: Python. Other languages: [C++](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants/js.md), [Swift](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants/swift.md).

A *default servant* is a servant that implements many Ice objects: for each request, it acts as the Ice object whose [identity](https://docs.zeroc.com/ice/3.8/runtime/object-identity/python.md) the request carries. With a default servant, an application can provide a very large number of Ice objects, for example one Ice object for each record of a database, without creating a servant for each of them.

## Registering a Default Servant

You register a default servant for a category, the value of the `category` field in the [identity](https://docs.zeroc.com/ice/3.8/runtime/object-identity/python.md) of the Ice objects it implements. [`addDefaultServant`](https://code.zeroc.com/ice/3.8/api/python/Ice.ObjectAdapter.html#Ice.ObjectAdapter.addDefaultServant) registers a default servant for a category, and [`removeDefaultServant`](https://code.zeroc.com/ice/3.8/api/python/Ice.ObjectAdapter.html#Ice.ObjectAdapter.removeDefaultServant) removes the default servant of a category and returns it. Each category has at most one default servant, but you can register the same servant for several categories.

When the [active servant map](https://docs.zeroc.com/ice/3.8/runtime/dispatch/active-servant-map/python.md) (ASM) of an object adapter has no servant for the identity and facet of a request, the object adapter dispatches this request to the default servant registered for the category of the identity. When there is no such default servant, it dispatches the request to the default servant registered for the empty category. A default servant receives the requests for all the facets of the Ice objects it implements.

## Implementing a Default Servant

A default servant finds the target Ice object from the identity in the `Current` object of each request. The `name` of the identity typically holds everything it needs, such as the key of a database record.

A default servant keeps no state for the Ice objects it implements: each dispatch reads the state of its Ice object, for example from a database.

A default servant that implements a skeleton generated by the Slice compiler implements a single interface, so all its Ice objects have this interface. To provide Ice objects with several interfaces this way, you can use one category per interface, such as `Sensor` and `Switch`, and register a default servant for each category. Using a non-empty category from the start makes it easier to add a default servant for another interface later.

## See Also

- [The Active Servant Map](https://docs.zeroc.com/ice/3.8/runtime/dispatch/active-servant-map/python.md)
- [Object Identity](https://docs.zeroc.com/ice/3.8/runtime/object-identity/python.md)
