Add some basic documentation for tenants
This commit is contained in:
parent
fc68cdf45f
commit
860ede0c2e
|
@ -26,6 +26,8 @@ FoundationDB supports language bindings for application development using the or
|
|||
|
||||
* :doc:`known-limitations` describes both long-term design limitations of FoundationDB and short-term limitations applicable to the current version.
|
||||
|
||||
* :doc:`tenants` describes the use of the tenants feature to define named transaction domains.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:titlesonly:
|
||||
|
@ -42,3 +44,4 @@ FoundationDB supports language bindings for application development using the or
|
|||
known-limitations
|
||||
transaction-profiler-analyzer
|
||||
api-version-upgrade-guide
|
||||
tenants
|
||||
|
|
|
@ -273,6 +273,16 @@ Directory partitions have the following drawbacks, and in general they should no
|
|||
* Directories in a partition have longer prefixes than their counterparts outside of partitions, which reduces performance. Nesting partitions inside of other partitions results in even longer prefixes.
|
||||
* The root directory of a partition cannot be used to pack/unpack keys and therefore cannot be used to create subspaces. You must create at least one subdirectory of a partition in order to store content in it.
|
||||
|
||||
Tenants
|
||||
-------
|
||||
|
||||
:doc:`tenants` in FoundationDB provide a way to divide the cluster key-space into named transaction domains. Each tenant has a byte-string name that can be used to open transactions on the tenant's data, and tenant transactions are not permitted to access data outside of the tenant. Tenants can be useful for enforcing separation between unrelated use-cases.
|
||||
|
||||
Tenants and directories
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Because tenants enforce that transactions operate within the tenant boundaries, it is not recommended to use a global directory layer shared between tenants. It is possible, however, to use the directory layer within each tenant. To do so, simply use the directory layer as normal with tenant transactions.
|
||||
|
||||
Working with the APIs
|
||||
=====================
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
#######
|
||||
Tenants
|
||||
#######
|
||||
|
||||
.. warning :: Tenants are currently experimental and are not recommended for use in production.
|
||||
|
||||
FoundationDB provides a feature called tenants that allow you to configure one or more named transaction domains in your cluster. A transaction domain is a key-space in which a transaction is allowed to operate, and no tenant operations are allowed to use keys outside the tenant key-space. Tenants can be useful for managing separate, unrelated use-cases and preventing them from interfering with each other. They can also be helpful for defining safe boundaries when moving a subset of data between clusters.
|
||||
|
||||
By default, FoundationDB has a single transaction domain that contains both the normal key-space (``['', '\xff')``) as well as the system keys (``['\xff', '\xff\xff')``) and the :doc:`special-keys` (``['\xff\xff', '\xff\xff\xff')``).
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
A tenant in a FoundationDB cluster maps a byte-string name to a key-space that can be used to store data associated with that tenant. This key-space is stored in the clusters global key-space under a prefix assigned to that tenant, with each tenant being assigned a separate non-intersecting prefix.
|
||||
|
||||
In addition to being each assigned a separate tenant prefix, tenants can be configured to have a common shared prefix. By default, the shared prefix is empty and tenants are allocated prefixes throughout the normal key-space. To configure an alternate shared prefix, set the ``\xff/tenantDataPrefix`` key to have the desired prefix as the value.
|
||||
|
||||
Tenant operations are implicitly confined to the key-space associated with the tenant. It is not necessary for client applications to use or be aware of the prefix assigned to the tenant.
|
||||
|
||||
Enabling tenants
|
||||
================
|
||||
|
||||
In order to use tenants, the cluster must be configured with an appropriate tenant mode using ``fdbcli``::
|
||||
|
||||
fdb> configure tenant_mode=<MODE>
|
||||
|
||||
FoundationDB clusters support the following tenant modes:
|
||||
|
||||
* ``disabled`` - Tenants cannot be created or used. Disabled is the default tenant mode.
|
||||
* ``optional_experimental`` - Tenants can be created. Each transaction can choose whether or not to use a tenant. This mode is primarily intended for migration and testing purposes, and care should be taken to avoid conflicts between tenant and non-tenant data.
|
||||
* ``required_experimental`` - Tenants can be created. Each normal transaction must use a tenant. To support special access needs, transactions will be permitted to access the raw key-space using the ``RAW_ACCESS`` transaction option.
|
||||
|
||||
Creating and deleting tenants
|
||||
=============================
|
||||
|
||||
Tenants can be created and deleted using the ``\xff\xff/management/tenant_map/<tenant_name>`` :doc:`special key <special-keys>` range as well as by using APIs provided in some language bindings.
|
||||
|
||||
Tenants can be created with any byte-string name that does not begin with the ``\xff`` character. Once created, a tenant will be assigned an ID and a prefix where its data will reside.
|
||||
|
||||
In order to delete a tenant, it must first be empty. If a tenant contains any keys, they must be cleared prior to deleting the tenant.
|
||||
|
||||
Using tenants
|
||||
=============
|
||||
|
||||
In order to use the key-space associated with an existing tenant, you must open the tenant using the ``Database`` object provided by your language binding. The resulting ``Tenant`` object can be used to create transactions much like with a ``Database``, and the resulting transactions will be restricted to the tenant's key-space.
|
||||
|
||||
All operations performed within a tenant transaction will occur within the tenant key-space. It is not necessary to use or even be aware of the prefix assigned to a tenant in the global key-space. Operations that could resolve outside of the tenant key-space (e.g. resolving key selectors) will be clamped to the tenant.
|
||||
|
||||
.. note :: Tenant transactions are not permitted to access system keys.
|
||||
|
||||
Raw access
|
||||
----------
|
||||
|
||||
When operating in the tenant mode ``required_experimental``, transactions are not ordinarily permitted to run without using a tenant. In order to access the system keys or perform maintenance operations that span multiple tenants, it is required to use the ``RAW_ACCESS`` transaction option to access the global key-space. It is an error to specify ``RAW_ACCESS`` on a transaction that is configured to use a tenant.
|
||||
|
||||
.. note :: Setting the ``READ_SYSTEM_KEYS`` or ``ACCESS_SYSTEM_KEYS`` options implies ``RAW_ACCESS`` for your transaction.
|
||||
|
||||
.. warning :: Care should be taken when using raw access to run transactions spanning multiple tenants if the tenant feature is being utilized to aid in moving data between clusters. In such scenarios, it may not be guaranteed that all of the data you intend to access is on a single cluster.
|
Loading…
Reference in New Issue