Upload
timothy-tsvetkov
View
182
Download
0
Tags:
Embed Size (px)
Citation preview
Typical development problems and mistakes
Online TV for REN TVhttp://ren-tv.com
Timothy N. Tsvetkov2011, rubyc, Kiev
Evil Martians
Air and live
Genres
Personal playlists
REN TVis
The best Online TVin
Russia
Architecture
Planning
• We have planned API to develop
• CDN Video have planned API to develop
Real life
• CDN Video API changed
DDs
• BDD
• TDD
• CI
• ADD
• DDD
• ASP .NET MVC 1.0
Truth
• BDD — Body Dysmorphic Disorder
• TDD — Test Driven Development
• CI — Convergence insufficiency
• ADD — Attention Deficit Disorder
• DDD — DDD
Testing limitations
• We can’t test everything
• You can’t develop an algorithm to proof that your program is correct
• Testing is hard
• Tests have errors
• Not that effective at finding bugs
Race conditions
• Most developers don’t think about race conditions
• Validates uniqueness is not race conditions safe
• Some gems are not race conditions safe and it is your business to check them
Optimistic locking
• Each update to the record increments the lock_version column and the locking facilities ensure that the records instantiated twice will let the last one saved raise a StaleObjectError if the first was also updated
• Doesn’t work between actions like edit/update
Pessimistic locking
• SELECT FOR UPDATE
• FOR UPDATE causes the rows retrieved for by the SELECT statement to be locked as thought for update. This prevents them from being modified or deleted by other transactions until the current transaction ends
Advisory lock
• Locks that have application defined meanings
Advisory locks. Usage
Test on race conditions
• It is hard to find them and there is no tool for that
• You can use test hooks in your production code for testing them in your rspec
Deamons
• Erlang is great
• Node.js sucks
Deamons v. 1
• Rebar to install debs, compile and start
• Classical OTP: Supervisor + fetchers, monitors
Deamons v. 2
• Supervisors spawns workers
• Workers spawn fetchers and monitors them
• Worker never die
Deamons v. 3
• v. 1 without Rebar but with Runit
Investigate a problem
• Log everything you can
• strace, tcp dump, netcat, gdb
• etc
Special thankstoYaroslav Markin
Dumb questions