27
Typical development problems and mistakes Online TV for REN TV http://ren-tv.com Timothy N. Tsvetkov 2011, rubyc, Kiev

Rentv

Embed Size (px)

Citation preview

Page 1: Rentv

Typical development problems and mistakes

Online TV for REN TVhttp://ren-tv.com

Timothy N. Tsvetkov2011, rubyc, Kiev

Page 2: Rentv

Evil Martians

Page 3: Rentv

Air and live

Page 4: Rentv

Genres

Page 5: Rentv

Personal playlists

Page 6: Rentv

REN TVis

The best Online TVin

Russia

Page 7: Rentv
Page 8: Rentv
Page 9: Rentv

Architecture

Page 10: Rentv

Planning

• We have planned API to develop

• CDN Video have planned API to develop

Page 11: Rentv

Real life

• CDN Video API changed

Page 12: Rentv

DDs

• BDD

• TDD

• CI

• ADD

• DDD

• ASP .NET MVC 1.0

Page 13: Rentv

Truth

• BDD — Body Dysmorphic Disorder

• TDD — Test Driven Development

• CI — Convergence insufficiency

• ADD — Attention Deficit Disorder

• DDD — DDD

Page 14: Rentv

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

Page 15: Rentv

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

Page 16: Rentv

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

Page 17: Rentv

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

Page 18: Rentv

Advisory lock

• Locks that have application defined meanings

Page 19: Rentv

Advisory locks. Usage

Page 20: Rentv

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

Page 21: Rentv

Deamons

• Erlang is great

• Node.js sucks

Page 22: Rentv

Deamons v. 1

• Rebar to install debs, compile and start

• Classical OTP: Supervisor + fetchers, monitors

Page 23: Rentv

Deamons v. 2

• Supervisors spawns workers

• Workers spawn fetchers and monitors them

• Worker never die

Page 24: Rentv

Deamons v. 3

• v. 1 without Rebar but with Runit

Page 25: Rentv

Investigate a problem

• Log everything you can

• strace, tcp dump, netcat, gdb

• etc

Page 26: Rentv

Special thankstoYaroslav Markin

Page 27: Rentv

Dumb questions