- Gene Amdahl's Law
- How to improve concurrency
- Removing FIFO
- FIFO isn't really needed a lot of the time in a queue of jobs
- can ditch FIFO if order of jobs doesn't matter
- if order matters, have a job fire things that depend on it at completion
- fuzzy-FIFO
- have many head nodes with a top boundary
- worker can take job from any head node above top boundary
- lock_head() (PL/pgSQL)
EXECUTE 'SELECT id FROM'
|| ' jobs'
|| ' WHERE locked_at IS NULL'
|| ' ORDER BY id ASC'
|| ' LIMIT 1'
|| ' OFFSET' || relative_top
|| ' FOR UPDATE'
|| ' NOWAIT'
INTO locked;
- do this procedure with a spin lock
- skip lock ?
- MVCC
- FIFO isn't really needed a lot of the time in a queue of jobs
- Relax constraints
- Removing FIFO
- github.com/ryandotsmith/queue_classic
- dependencies
- pg gem
- json
- faster b/c it doesn't make a lot of object
- dependencies
- Code needs to work today just once, and be easy to change forever
- The purpose of design is to reduce the cost of change
- Simple ways to judge the goodness of code
- Transparent - the consesquences of change are visible and predictable
- Reasonalbe - the cost of adding a new feature is proportional to its value
- Usable - if you wrote it, you can reuse it
- Exemplary - More code like this would be good for your app
- Code will never be done, just need to know when to stop
- Slides: less-goruco.heroku.com
- Don't guess what changes will come, just guess what will change.
- Let objects stand free
- redis is single-threaded
- redis.pipelined
- ZeroMQ
- github.com/clr
- 2K Bot Competition
- Pogamut - team actions?
- TextMate bundle to compile/run coffeescript
- altjs.org
- SQL Operators
- Bulk inserts incredibly faster than regular inserts
- HAVING count(1) > 1
- Pagination
SELECT SQL_CALC_FOUND ROWS * FROM people WHERE face = 'awesome' LIMIT 10 OFFSET 20;
SELECT FOUND_ROWS();
- slim_scrooge github.com/sdskyes/slim_scrooge
- Learns to select only what's necessary
- Uses a lot of memory for bigger apps
- String Operators: strlen, left, right, concat, reverse
- DB regex:
SELECT 'John' REGEXP '^[a-zA-Z]+$';
- Think about setting max lengths for fields - could save a lot of space at scale
- validates_uniqueness_of doesn't work.
- :unique is property of index, not column
- github.com/seejohnrun/database_validation
- ENUMs - kind of like validates_inclusion_of
- pg adapter doesn't absoultely support - but gems exist to do so
- Single Table Inheritance
- if subclasses differ only in behavior, ok
- otherwise, use Class-Table Inheritance
- Superclass table stores common attributes
- Not supported by ActiveRecord
- Sleep is invisible in run times except real
- Huge real time may indicate blocking as well
- gist.github.com/1008305
- [email protected] for shirts
NIce Gordon!