Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Concurrency + Mongo
Search
gamechanger
August 21, 2012
Technology
0
110
Concurrency + Mongo
Concurrent Operations with MongoDB
gamechanger
August 21, 2012
Tweet
Share
More Decks by gamechanger
See All by gamechanger
Mongo: Performance and Troubleshooting
gamechanger
0
310
Mongo and Ops
gamechanger
0
110
Other Decks in Technology
See All in Technology
Operating Operator
shhnjk
1
620
インフラ寄りSREの生存戦略
sansantech
PRO
6
2.5k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
970
マネジメントって難しい、けどおもしろい / Management is tough, but fun! #em_findy
ar_tama
7
1.2k
ビジネス職が分析も担う事業部制組織でのデータ活用の仕組みづくり / Enabling Data Analytics in Business-Led Divisional Organizations
zaimy
1
210
Contributing to Rails? Start with the Gems You Already Use
yahonda
2
110
アクセスピークを制するオートスケール再設計: 障害を乗り越えKEDAで実現したリソース管理の最適化
myamashii
1
130
NewSQLや分散データベースを支えるRaftの仕組み - 仕組みを理解して知る得意不得意
hacomono
PRO
3
190
CDKコード品質UP!ナイスな自作コンストラクタを作るための便利インターフェース
harukasakihara
2
130
関数型プログラミングで 「脳がバグる」を乗り越える
manabeai
2
210
クラウド開発の舞台裏とSRE文化の醸成 / SRE NEXT 2025 Lunch Session
kazeburo
1
290
Coinbase™®️ USA Contact Numbers: Complete 2025 Support Guide
officialcoinbasehelpcenter
0
460
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
200k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Facilitating Awesome Meetings
lara
54
6.4k
A designer walks into a library…
pauljervisheath
207
24k
The Invisible Side of Design
smashingmag
301
51k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
700
Navigating Team Friction
lara
187
15k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
Transcript
concurrency + Mongo Doug Woos engineer, gamechanger Monday, August 20,
12
Concurrency • Multiple, interacting computations • Processes modifying same or
dependent records • Relational: solved with transactions (2PC) • Mongo: no transactions (right?) • So, how do we do this? Monday, August 20, 12
Examples • Multiple users scoring one game • One user,
scoring on device, following on web • Background updates run on multiple nodes Monday, August 20, 12
atomic updates • $set, $unset, $inc, $push, $pull, $addToSet .
. . • $ operator, upserts . . . • findAndModify Monday, August 20, 12
Atomic Updates • Don’t support all operations • Schema design
important! • If we need to do a read first, can’t use Monday, August 20, 12
Isolation Queue • Do all modifications in a queue processor
• Only allow a record to be in the queue once • Compare to Java “synchronized” (monitor) Monday, August 20, 12
Isolation Queue • Part of the Dockets library • github.com/gamechanger/dockets
• Guarantees: • Updates will not conflict • Last update will be run • Intermediate updates may not be Monday, August 20, 12
Isolation Queue • Requires a queue • Not everything can
be async • Slower than Mongo atomic operators Monday, August 20, 12
Optimistic Transactions • Like Redis, sort of • Don’t lock,
but detect conflicts using save_date Monday, August 20, 12
Monday, August 20, 12
Optimistic Transactions • Single-record only • Slower than atomic updates
• Inefficient when there’s a lot of contention Monday, August 20, 12
Conclusions • Safe concurrency != ACID • Schema design is
important • No one-size-fits-all solutions in NoSQL! Monday, August 20, 12