---
name: "DBIx::Class::Storage::DBI::Replicated::Balancer::Random"
section: "3pm"
platform: "linux"
package: "libdbix-class-perl"
version: "0.082844-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/DBIx::Class::Storage::DBI::Replicated::Balancer::Random"
---

# DBIx::Class::Storage::DBI::Replicated::Balancer::Random(3pm)

A 'random' Balancer

## NAME

DBIx::Class::Storage::DBI::Replicated::Balancer::Random - A 'random' Balancer

## SYNOPSIS

This class is used internally by DBIx::Class::Storage::DBI::Replicated.  You shouldn't need to create instances of this class.

## DESCRIPTION

Given a pool (DBIx::Class::Storage::DBI::Replicated::Pool) of replicated database's (DBIx::Class::Storage::DBI::Replicated::Replicant), defines a method by which query load can be spread out across each replicant in the pool.

## ATTRIBUTES

This class defines the following attributes.

### master\_read\_weight

A number greater than 0 that specifies what weight to give the master when choosing which backend to execute a read query on. A value of 0, which is the default, does no reads from master, while a value of 1 gives it the same priority as any single replicant.

For example: if you have 2 replicants, and a "master\_read\_weight" of `0.5`, the chance of reading from master will be `"20%"`.

You can set it to a value higher than 1, making master have higher weight than any single replicant, if for example you have a very powerful master.

## METHODS

This class defines the following methods.

### next\_storage

Returns an active replicant at random.  Please note that due to the nature of the word 'random' this means it's possible for a particular active replicant to be requested several times in a row.

## FURTHER QUESTIONS?

Check the list of additional DBIC resources.

## COPYRIGHT AND LICENSE

This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.
