High performance C++ framework for concurrent servers
Classes | Public Member Functions | Related Functions | List of all members
seastar::fair_queue Class Reference

Detailed Description

Fair queuing class.

This is a fair queue, allowing multiple request producers to queue requests that will then be served proportionally to their classes' shares.

To each request, a weight can also be associated. A request of weight 1 will consume 1 share. Higher weights for a request will consume a proportionally higher amount of shares.

The user of this interface is expected to register multiple priority_class objects, which will each have a shares attribute.

Internally, each priority class may keep a separate queue of requests. Requests pertaining to a class can go through even if they are over its share limit, provided that the other classes have empty queues.

When the classes that lag behind start seeing requests, the fair queue will serve them first, until balance is restored. This balancing is expected to happen within a certain time window that obeys an exponential decay.

#include <seastar/core/fair_queue.hh>


struct  config
 Fair Queue configuration structure. More...

Public Member Functions

 fair_queue (fair_group &shared, config cfg)
priority_class_ptr register_priority_class (uint32_t shares)
void unregister_priority_class (priority_class_ptr pclass)
size_t waiters () const
size_t requests_currently_executing () const
fair_queue_ticket resources_currently_waiting () const
fair_queue_ticket resources_currently_executing () const
void queue (priority_class_ptr pc, fair_queue_entry &ent)
void notify_requests_finished (fair_queue_ticket desc, unsigned nr=1) noexcept
void notify_request_cancelled (fair_queue_entry &ent) noexcept
void dispatch_requests (std::function< void(fair_queue_entry &)> cb)
 Try to execute new requests if there is capacity left in the queue.
clock_type next_pending_aio () const noexcept

Related Functions

(Note that these are not member functions.)

using priority_class_ptr = lw_shared_ptr< priority_class >
 Priority class, to be used with a given fair_queue. More...

Class Documentation

◆ seastar::fair_queue::config

struct seastar::fair_queue::config
Class Members
microseconds tau
float ticket_size_pace
float ticket_weight_pace

Constructor & Destructor Documentation

◆ fair_queue()

seastar::fair_queue::fair_queue ( fair_group shared,
config  cfg 

Constructs a fair queue with configuration parameters cfg.

cfgan instance of the class config

Member Function Documentation

◆ notify_requests_finished()

void seastar::fair_queue::notify_requests_finished ( fair_queue_ticket  desc,
unsigned  nr = 1 

Notifies that ont request finished

descan instance of fair_queue_ticket structure describing the request that just finished.

◆ queue()

void seastar::fair_queue::queue ( priority_class_ptr  pc,
fair_queue_entry ent 

Queue the entry ent through this class' fair_queue

The user of this interface is supposed to call notify_requests_finished when the request finishes executing - regardless of success or failure.

◆ register_priority_class()

priority_class_ptr seastar::fair_queue::register_priority_class ( uint32_t  shares)

Registers a priority class against this fair queue.

shareshow many shares to create this class with

◆ requests_currently_executing()

size_t seastar::fair_queue::requests_currently_executing ( ) const
the number of requests currently executing

◆ resources_currently_executing()

fair_queue_ticket seastar::fair_queue::resources_currently_executing ( ) const
the amount of resources (weight, size) currently executing

◆ resources_currently_waiting()

fair_queue_ticket seastar::fair_queue::resources_currently_waiting ( ) const
how much resources (weight, size) are currently queued for all classes.

◆ unregister_priority_class()

void seastar::fair_queue::unregister_priority_class ( priority_class_ptr  pclass)

Unregister a priority class.

It is illegal to unregister a priority class that still have pending requests.

◆ waiters()

size_t seastar::fair_queue::waiters ( ) const
how many waiters are currently queued for all classes.

The documentation for this class was generated from the following file: