๋ฐ์ํ
Intro
mongodb์ read preference์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค.
Read Preference?
read preference๋ mongo db์์ replica set ์ค์ ์ primary, secondary์ ๋ํ ์ค์ ์ ๋๋ค. ์ด๋ฅผ ์ํด mongo db๋ 5๊ฐ์ง ๋ฐฉ๋ฒ์ ์ง์ํ๊ณ ์์ต๋๋ค.
Read Preference ModeDescription
Default mode. All operations read from the current replica set primary.
Multi-document transactions that contain read operations must use read preference primary. All operations in a given transaction must route to the same member. |
|
In most situations, operations read from the primary but if it is unavailable, operations read from secondary members.
Starting in version 4.4, primaryPreferred supports hedged reads on sharded clusters. |
|
All operations read from the secondary members of the replica set.
Starting in version 4.4, secondary supports hedged reads on sharded clusters. |
|
In most situations, operations read from secondary members but if no secondary members are available, operations read from the primary on sharded clusters.
Starting in version 4.4, secondaryPreferred supports hedged reads on sharded clusters. |
|
Operations read from a random eligible replica set member, irrespective of whether that member is a primary or secondary, based on a specified latency threshold. The operation considers the following when calculating latency:
|
- primary : ๋ชจ๋ ๋ช ๋ น์ด primary์์๋ง ๋์ํฉ๋๋ค.
- primaryPreferred : primary๊ฐ unavilable ํ ๊ฒฝ์ฐ, read operation์ secondary๋ก ์ ๋ฌํฉ๋๋ค.
- secondary : ๋ชจ๋ read ๋ช ๋ น์ secondary๋ก ๋ณด๋ด ์ฒ๋ฆฌํฉ๋๋ค.
- secondaryPreferred : secondary members ๋ชจ๋ unavilable ํ ๊ฒฝ์ฐ read ๋ช ๋ น์ primary๋ก ๋๊ฒจ ์ฒ๋ฆฌํฉ๋๋ค.
- nearest : primary, secondary ์๊ด์์ด latency threshold๊ฐ ๊ฐ์ ์ ์ ์ธ์คํด์ค๋ก ๋ณด๋ด ์ฒ๋ฆฌํฉ๋๋ค.
๋ฐ์ํ