Mixer Service

Mixer

Mixer provides three core features:

  • Precondition Checking. Enables callers to verify a number of preconditions before responding to an incoming request from a service consumer. Preconditions can include whether the service consumer is properly authenticated, is on the service’s whitelist, passes ACL checks, and more.

  • Telemetry Reporting. Enables services to report logging and monitoring. In the future, it will also enable tracing and billing streams intended for both the service operator as well as for service consumers.

  • Quota Management. Enables services to allocate and free quota on a number of dimensions, Quotas are used as a relatively simple resource management tool to provide some fairness between service consumers when contending for limited resources. Rate limits are examples of quotas.

Check

  rpc Check(CheckRequest) returns (CheckResponse)

Checks preconditions before performing an operation. The preconditions enforced depend on the set of supplied attributes and the active configuration.

Quota

  rpc Quota(QuotaRequest) returns (QuotaResponse)

Quota allocates and releases quota.

Report

  rpc Report(ReportRequest) returns (ReportResponse)

Reports telemetry, such as logs and metrics. The reported information depends on the set of supplied attributes and the active configuration.

Attributes

An instance of this message is delivered to Mixer with every API call.

The general idea is to leverage the stateful gRPC streams from the Envoy to Mixer to keep to a minimum the ‘attribute chatter’. Only delta attributes are sent over, multiple concurrent attribute contexts can be used to avoid thrashing, and attribute indices are used to keep the wire protocol maximally efficient.

Producing this message is the responsibility of Mixer’s client library which is linked into different proxy implementations.

The processing order for this state in Mixer is:

  • Any new dictionary is applied

  • The requested attribute context is looked up. If no such context has been defined, a new context is automatically created and initialized to the empty state. When a gRPC stream is first created, there are no attribute contexts for the stream.

  • If resetContext is true, then the attribute context is reset to the empty state.

  • All attributes to deleted are removed from the attribute context.

  • All attribute changes are applied to the attribute context.

FieldTypeDescription
dictionaryrepeated map<int32, string>

A dictionary that provides a mapping of shorthand index values to attribute names.

This is intended to leverage the stateful gRPC stream from the proxy to the mixer. This dictionary is sent over only when a stream to the mixer is first established and when the proxy's configuration changes and different attributes may be produced.

Once a dictionary has been sent over, it stays in effect until a new dictionary is sent to replace it. The first request sent on a stream must include a dictionary, otherwise the mixer can't process any attribute updates.

Dictionaries are independent of the attribute context and are thus global to each gRPC stream.

attributeContextint32

The attribute context against which to operate.

The mixer keeps different contexts live for any proxy gRPC stream. This allows the proxy to maintain multiple concurrent 'bags of attributes' within the mixer.

If the proxy doesn't want to leverage multiple contexts, it just passes 0 here for every request.

The proxy is configured to use a maximum number of attribute contexts in order to prevent an explosion of contexts in the mixer's memory space.

resetContextbool

When true, resets the current attribute context to the empty state before applying any incoming attributes.

Resetting contexts is useful to constrain the amount of resources used by the mixer. The proxy needs to intelligently manage a pool of contexts. It may be useful to reset a context when certain big events happen, such as when an HTTP2 connection into the proxy terminates.

stringAttributesrepeated map<int32, string>Attributes being updated within the specified attribute context. These maps add and/or overwrite the context's current set of attributes.
int64Attributesrepeated map<int32, int64>
doubleAttributesrepeated map<int32, double>
boolAttributesrepeated map<int32, bool>
timestampAttributesrepeated map<int32, Timestamp>
durationAttributesrepeated map<int32, Duration>
bytesAttributesrepeated map<int32, bytes>
stringMapAttributesrepeated map<int32, StringMap>
deletedAttributes[]repeated int32Attributes that should be removed from the specified attribute context. Deleting attributes which aren't currently in the attribute context is not considered an error.
timestampAttributesHACKrepeated map<int32, Timestamp>
durationAttributesHACKrepeated map<int32, Duration>

CheckRequest

Used to verify preconditions before performing an action.

FieldTypeDescription
requestIndexint64Index within the stream for this request, used to match to responses
attributeUpdateAttributesThe attributes to use for this request

CheckResponse

FieldTypeDescription
requestIndexint64Index of the request this response is associated with
attributeUpdateAttributesThe attributes to use for this response
resultStatusIndicates whether or not the preconditions succeeded
expirationDurationThe amount of time for which this result can be considered valid, given the same inputs

QuotaRequest

FieldTypeDescription
requestIndexint64Index within the stream for this request, used to match to responses
attributeUpdateAttributesThe attributes to use for this request
deduplicationIdstringUsed for deduplicating quota allocation/free calls in the case of failed RPCs and retries. This should be a UUID per call, where the same UUID is used for retries of the same quota allocation call.
quotastringThe quota to allocate from.
amountint64The amount of quota to allocate.
bestEffortboolIf true, allows a response to return less quota than requested. When false, the exact requested amount is returned or 0 if not enough quota was available.

QuotaResponse

FieldTypeDescription
requestIndexint64Index of the request this response is associated with.
attributeUpdateAttributesThe attributes to use for this response
resultStatusIndicates whether the quota request was successfully processed.
expirationDurationThe amount of time the returned quota can be considered valid, this is 0 for non-expiring quotas.
amountint64The total amount of quota returned, may be less than requested.

ReportRequest

Used to report telemetry after performing an action.

FieldTypeDescription
requestIndexint64Index within the stream for this request, used to match to responses
attributeUpdateAttributesThe attributes to use for this request

ReportResponse

FieldTypeDescription
requestIndexint64Index of the request this response is associated with
attributeUpdateAttributesThe attributes to use for this response
resultStatusIndicates whether the report was processed or not

StringMap

A map of string to string. The keys in these maps are from the current dictionary.

FieldTypeDescription
maprepeated map<int32, string>