random tips that will save your project's life

Download Random tips that will save your project's life

If you can't read please download the document

Upload: mariano-iglesias

Post on 16-Apr-2017

1.843 views

Category:

Technology


0 download

TRANSCRIPT

Random tips

They will save your life(for real)

@mgiglesias

CakeFest 2012 Manchester, UK

411

I use CakePHP, Lithium, Doctrine2, Python, Node.js, C++ Yes. C++

I like beer

I have 4 dogs, 4 cats, and a horse Yes. A horse

I co-founded WORKANAhttps://www.workana.com

GIT & deploys

I shouldn't even have to say this

Master branch should be 100% pushableFeature branches like there's no tomorrow

Code reviews

Python scripts, but you could use Capistrano or whatever

Could have hundred deploys per dayYes, you do need UT

Monit

* SHIT HAPPENS* QA is nice, Unit Testing is nice, but monitoring is GREAT

Monit

Don't PING-monitor me, please

Monit the heck out of your servers

Track the PHP logs (say what?)

Be pre-emptive with your actions

Monit

# Redischeck process redis with pidfile /var/run/redis/redis-server.pidstart program = "/etc/init.d/redis-server start"stop program = "/etc/init.d/redis-server stop"if failed port 6379 protocol http then restartif loadavg(5min) greater than 10.0 for 8 cycles then stopif 3 restarts within 5 cycles then timeoutdepends on redis_bin

# Redis binarycheck file redis_bin with path /usr/bin/redis-serverif failed checksum then unmonitorif failed permission 755 then unmonitorif failed uid root then unmonitorif failed gid root then unmonitorif changed timestamp then alert

# log parsercheck program log_parser_app with path "/var/www/scripts/log_parser.sh"if status != 0 then alert

Ducksboard

* You POST your data through REST (increment, discrete value)* Realtime updates* Built-in widgets (facebook, twitter, pingdom, everything)

Statsd

Built on Node.js (what else)

Works through UDP (UDP you say?)

Easy from PHP: StatsD::timing("grue.dinners", (microtime(true) - $start) * 1000);

Integrate with Graphite for even more coolness

* Node.js: super-easy deployment and high availability (MONIT)* UDP: Super fast, not guaranteed delivery. The idea is for the site (and statsd) to always be available* Graphite: storage backend, you HTTP post to it from Statsd data

Statsd

Google Analytics

Tracking (force URLs)

Conversions (get the paths)

Real Time (loose the little free time you have)

A/B testing (of everything)

Varnish

Speed: do I need to say more?

Home page and signup: should be super-fast

Base caching rules on URLs

Ideal for non-registered content

Cache invalidation from PHP through socket

* Check the lighting talk from MAN 2011* Speed: can get you a 1000x speed increase* Non-registered: check for session vars. MAKE SURE you are not sending non-cache session headers, Varnish listens to that (PHP sends non-cache headers when sessions are enabled by default. In varnish rules you can check for specific HTTP cookies* Cache invalidation: https://github.com/timwhitlock/php-varnish

On AWS

* CLOUD FRONT: Invalidation works, but still use ?version numbers. Today they added CROSS (Cross Origin Resource Sharing) support* EBS: SSL termination* Sessions on central storage like Redis* Separate ELB for notifications* Get pre-paid instances when possible

Parse incoming email

Stop making me go to your F** website

No need for different reply-toMessage ID to the rescue! [email protected]

Sendgrid hits your server on each replyYou get the $_FILES too!

Avoids sending emails to bounces, good reporting!

Real time notifications

It's not rocket science

PHP (gearman?) Redis pub/sub

Redis pub/sub Node.js

Client Node.js through Socket.io

Socket.io channels (per user hash)

Sphinx

RU doin' fulltext search? What's wrong with you?

Ridiculously fast and highly scalable

Indexes right out of your RDBMSDelta indexes

More than just text fields

PECL extension or SQL (say what?)

Real time indexing (comes with some gotchas)

* Delta indexes: one index for old stuff, one index for newer (less) stuff. You can then merge the two which is faster than full reindex* More FIELDS: you can take into your index stuff that you would normally need MySQL for (calculated stuff for example?)* RT: no prefix/infix indexing. You use the MySQL protocol to INSERT rows

Questions?

@mgiglesias

CakeFest 2012 Manchester, UK