from dev to ops and beyond - getting it done

59
FROM DEV TO OPS AND BEYOND GETTING IT DONE Volker Dusch / @_ _edorian

Upload: edorian

Post on 25-Dec-2014

3.688 views

Category:

Technology


2 download

DESCRIPTION

About the importance and journy to shipping and DevOps

TRANSCRIPT

Page 1: From dev to ops and beyond - getting it done

FROM DEV TO OPS ANDBEYOND

GETTING IT DONE

Volker Dusch / @_ _edorian

Page 2: From dev to ops and beyond - getting it done

ABOUT MESoftware EngineerPHP since 11 yearsCICleanCodeDevOpsTDDShippingBullet points

Page 3: From dev to ops and beyond - getting it done

INSTEAD OF ME

Page 4: From dev to ops and beyond - getting it done

WORKING FOR

ResearchGate gives science back to the people who make it happen.

We help researchers build reputation and accelerate scientificprogress.

On their terms.

Page 5: From dev to ops and beyond - getting it done

GET IN TOUCH

stackoverflow: Twitter: @_ _edorianG+: Volker DuschIRC: edorianMail: [email protected]

Page 6: From dev to ops and beyond - getting it done

AGENDAWe will look at what is necessarily to keep shipping a successful

product beyond its initial release and what role we developers shouldbe playing in this.

Development practicesPlanning and CommunicationDeployment and OperationsYMMV

Page 7: From dev to ops and beyond - getting it done

BUT BEFORE WE GET GOINGTime for a little exercise

Page 8: From dev to ops and beyond - getting it done

10 YEARS AGOHOW I GOT HOOKED ON CREATING STUFF ON THE

WEBCreating things is awesomeIt was super easy and fun

Page 9: From dev to ops and beyond - getting it done

10 YEARS AGOCUSTOMERS

"We want a website!""Can you fix this little thing please?""What do you mean you're already done?"

Page 10: From dev to ops and beyond - getting it done

10 YEARS AGOWHAT I DIDN'T KNOW BACK THEN

Things got bigger, a lot bigger"Web applications" vs. "Websites"Maintaining things was really hardIt's about more than just programming

Page 11: From dev to ops and beyond - getting it done

INTERMISSION

Page 12: From dev to ops and beyond - getting it done

INTERMISSION

Page 13: From dev to ops and beyond - getting it done

MY FIRST WEB APPLICATION6 devs, growing to 20Big code baseQuite some data, for the timeThis talk is about everything we had to take care of, and more

Page 14: From dev to ops and beyond - getting it done

SHIPPING BIGGER THINGS

Page 15: From dev to ops and beyond - getting it done

LET'S SHIP IT!THINGS TO TAKE CARE OF

Fulfilling current requirementsFiguring out what to do nextDelivery and Operations

ASK QUESTIONS AT ANY TIME!

Page 16: From dev to ops and beyond - getting it done

WE'RE DEVELOPERSLet's start with us!We get paid to do what we loveMost of us started because we where fascinated by programmingBut what is our job?

Page 17: From dev to ops and beyond - getting it done

OUR JOB IS TO DELIVERGet things doneGive good estimatesAsk the right questionsKeep doing thatDon't slow downKeep our promises

Page 18: From dev to ops and beyond - getting it done

THE COST OF HAVING US FOLKS AROUND

German numbers, YMMV €, Approximations

Salary: ~50k a year 50.000€ / Year

Adding non-wage labor cost 80.000€ / Year

Office space, water, hardware, coffee,plants, cleaning, travels, training

100.000€ / Year

Weekends, holidays, vacation, etc:We works 220 days a year.

455€ / day

"Classic" 8 hour work day 55 Bucks per Hour!

We are expected to contribute over 100.000 Bucks in business valueper year!

Page 19: From dev to ops and beyond - getting it done

HOW?Evaluate everything you're doing by a simple question:

“Does the practice in question help us to continuouslyship what our business needs to succeed?”

Page 20: From dev to ops and beyond - getting it done

CODERules for structuring our source code that have proven to help with

sustainability.

Page 21: From dev to ops and beyond - getting it done

THE MOST BASIC THING:Separate the web-glue from the business logic.

Keep templates stupidHave services owning the logic for manipulation of business entitiesHide the data access behind a layer that you can maintainindividually

Page 22: From dev to ops and beyond - getting it done

SOLIDSingle responsibilityOpen-closedLiskov substitutionInterface segregationDependency inversion

http://en.wikipedia.org/wiki/SOLID(object-orienteddesign)

Page 23: From dev to ops and beyond - getting it done

COMPOSITION OVER INHERITANCEDon't inherit from things if you can just use them.

http://c2.com/cgi/wiki?CompositionInsteadOfInheritance

http://en.wikipedia.org/wiki/Compositionoverinheritance

Page 24: From dev to ops and beyond - getting it done

DEPENDENCY INJECTION

This goes for you code base as well as for your whole Company.

Allows for quick and easy reuse of small componentsIf wiring is to hard people will copy/paste insteadCan be achieved in many ways. Pick one that works for you

http://pimple.sensiolabs.org/http://symfony.com/doc/current/components/dependency_injection/index.htmlhttps://github.com/researchgate/injektor

“In the end - everything is a wiring problem.”

Page 25: From dev to ops and beyond - getting it done

REUSING CODEThe Dependency Manager for PHP

As easy as committing everything to your SCM. But with care freeautoloading.

Page 26: From dev to ops and beyond - getting it done

TESTINGThe art of making sure that you notice failures before your customers

do.

Testing exist to give you confidence when moving forward.

Page 27: From dev to ops and beyond - getting it done

THE FASTEST THING YOU CAN DO

Staging serverTesting your buildsAll without even touching Behat or PHPUnit

hits=̀curl -s staging.project.com | grep 'Login:' | wc -l̀;test $hits -eq 1 || echo "Frontpage error!"

data="login=test&passwort=secure&csrf="$csrfTokenurl="staging.project.com"hits=̀curl -X POST -d $data $url | grep 'Hello, testuser' | wc -l̀;test $hits -eq 1 || echo "Login error!"

Page 28: From dev to ops and beyond - getting it done

OTHER DEPARTMENTS DON'T CARE ABOUT UNIT TESTINGNor should they!

Your fellow developers on the other hand ... :)

“The mechanic fixing your car doesn't ask you whatsong she should listen to while performing the task.”

Page 29: From dev to ops and beyond - getting it done

CONVENTIONAL WISDOM

Page 30: From dev to ops and beyond - getting it done

BUT TESTING IS HAAAARDWriting proper code is hardThe harder it is to use the code in question, the harder is writing testsfor itComplex tests means the code is to complex. Break it down.If anything: Mocking is hard(-ish).

Phake is your friend:http://phake.digitalsandwich.com/docs/html/FBMock: Mocking for grown ups:https://github.com/facebook/FBMockThe PHPUnit mocking API is still good enough.

Page 31: From dev to ops and beyond - getting it done

TDDWriting tests can feel like extra work if you are rethinking an already

solved problem

TDD offers a way to first think about the problem, the interface andthe interactions and then filling in the details step by step until you are

done with the bigger picture.

Page 32: From dev to ops and beyond - getting it done

QUICK WINS WITH BEHATWeb tests help you detect a big amount of wiring issues with littleeffortBefore growing to many of them consider maintenance"Full stack testing" will allow you to ship with great confidence

Page 33: From dev to ops and beyond - getting it done

ENSURING MAINTAINABILITYGetting rid of all the things you might stumble over

Page 34: From dev to ops and beyond - getting it done

CODE REVIEWThere are a lot of ways to go about this

Small teams can use commit based reviewWhen feature branching the merge back is a natural pointInternal coding DojoPair programmingSend emails when important changes occur

The main point of these ideas is to make sure everyone has a goodunderstanding of how common things are solved and to keep people

communicating.

Page 35: From dev to ops and beyond - getting it done

CODING GUIDELINESA collection for formatting and structure rules so that everyone can

easily find their way around and produce uniform code.

Just create the rule set fitting your practicesAdapt when there is painDon't over analyze. Just do it

PHP CodeSniffer:

http://pear.php.net/package/PHP_CodeSnifferhttp://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.phphttp://edorian.github.io/php-coding-standard-generator/#phpcs

“Coding rules:It doesn't matter what they are - as long as you have

them.”

Page 36: From dev to ops and beyond - getting it done

COMPLEXITY GUIDELINESSimilar to a coding standard but focusing on hunting down potential

problems within your source code

Possible bugsSuboptimal codeOvercomplicated expressionsUnused parameters, methods, properties

PHP MessDetector:

http://phpmd.org/http://phpmd.org/rules/http://edorian.github.io/php-coding-standard-generator/#phpmd

Page 37: From dev to ops and beyond - getting it done

CONTINUOUS DEVELOPMENT PACE"Done" means there is nothing left to clean upEvery once in a while you plan time to throw away things"Having a clean slate" is an attitude and a culture

“There are only two hard problems in ComputerScience: cache invalidation, naming things, and off-

by-one errors.”

Page 38: From dev to ops and beyond - getting it done

CIHave a automated way of checking all the things you agreed on

Run web and unit testsEnsure coding guidelinesEnsure complexity guidelinesKeep the project deploying :)

Tools:

http://jenkins-ci.orghttp://jenkins-php.orghttp://www.sonarsource.org

Page 39: From dev to ops and beyond - getting it done

WORKING IN SHORTITERATIONS

Every iteration is a chance for people to "sync" their Vision of theproduct with the current reality.

Page 40: From dev to ops and beyond - getting it done

SHIPPING REDUCES COMPLEXITY"Did we already implement this a month ago?""That bug you just reported was fixed 2 weeks ago. Just notdeployed yet"Shipping let's you discover what doesn't work before you spend toomuch time on it.

Page 41: From dev to ops and beyond - getting it done

PLANNING CAN BE A BIG MINDSET CHANGE“Nobody told me my job involved talking to... people”

Page 42: From dev to ops and beyond - getting it done

ASSUME COMPETENCEWork with the basic mind set that other people are at least as good in

their job as you are in yours.

If they tell you to do "stupid" things find out what they want toachieveCompany "vision" is a big hereJust know what you want to get done and work together

Page 43: From dev to ops and beyond - getting it done

HAVING EVERYONE INVOLVEDGetting everyone in the same boat and working towards a common

goal will speed you up like nothing else every will.

ProductDesignCopyrightingEngineering""Upper management""

If you can ensure that everyone was involved somewhere in the loopyou spend way less time on re-discussing and avoid confusion.

Page 44: From dev to ops and beyond - getting it done

HONESTY SOLVES A LOT MORE ISSUES THAN ITCREATESTrue story.

Page 45: From dev to ops and beyond - getting it done

TOOLINGTooling is needed when people can't get the information they need

A wall with Post'it notes and a stack of story cards might be all youneedWhen working remote spend time on making it look beautiful so thatpeople look at ithttps://trello.com/$millionOfOtherProducts

Page 46: From dev to ops and beyond - getting it done

BUGSTechnical errorsCommunication errors (and forgotten features)Fix the technical issues quickly to reduce complexityDon't build "bug management".But at a certain size you need someone to dispatch bugs to safeeveryone time

Page 47: From dev to ops and beyond - getting it done

STATSState are awesome!Knowing what your users actually do with your software is valuableSeeing them use the new thing you build is - like - the best ever(tm).StatsD: https://github.com/etsy/statsd/Graphite: http://graphite.wikidot.com/

Page 48: From dev to ops and beyond - getting it done

OPS AND DEVOPSIf it's not in production it doesn't really count.

Page 49: From dev to ops and beyond - getting it done

CLASSIC APPROACH

Page 50: From dev to ops and beyond - getting it done

DEVOPSTalking to the people getting up at night so you don't have to.

Your SysAdmins care. A lot!It's your job to figure out a way to constantly deploy withoutbreaking thingsAutomation helps avoiding errors

Page 51: From dev to ops and beyond - getting it done

BUILD AND DEPLOYMENT TOOLINGA collection of scripts that gets you from "source code" to "running in

production".

Create a buildCan be done in Jenkins. Still keep it in a script and let Jenkins runit.Run unit testsRun integration, functional testsReport on coding/complexity metrics

Once you are confident that things are going to go wellDeploy the build to a staging environmentRun web testsDeploy to productionRollback when really really needed

That's it. No magic - Just detail work.

Page 52: From dev to ops and beyond - getting it done

HOW TO GET THAT SCRIPT?It doesn't matter what language you write that tooling in. There is no

generic answer.

Chances are there is going to be a lot of BASH in it.Whatever calls your BASH script isn't all that importantAntMore custom BASHAnt Build CommonsSF2 CLI commandsWhatever works. As long as you can maintain it and it's stable.Don't over-engineer. You'll iterate a lot over this.

Page 53: From dev to ops and beyond - getting it done

LINKShttp://abc.tools.qafoo.cohttp://www.capistranorb.com/Example Ant: http://jenkins-php.orghttp://symfony.com/doc/current/components/console/introduction.html

Page 54: From dev to ops and beyond - getting it done

PROVISIONINGGetting servers and development environments in a known state

Having the SAME versions on dev and prod is invaluable.The only documentation that gets always updated is the code.Being able to recreate servers safes a lot of hassle.Think about your firewalls :)

Having a virtual machine per project keeps you sane

http://www.vagrantup.com/https://puppetlabs.com/http://www.opscode.com/chef/

Page 55: From dev to ops and beyond - getting it done

CONFIGURATION MANAGEMENTAny solution will require close collaboration with the folks running the

production boxes or lead to hassle.

Config files in puppet/chefConfigs for all systems in the SCM and only reading in environmentsSetting systems up in a way that they always look the same

Page 56: From dev to ops and beyond - getting it done

DATA MIGRATIONSThis questions comes up a lot when talking about automation. There is

no easy answer.

Very specific to your project and environmentUsually not possible to have downtime while data is migratedDon't throw away DB columns when you change the code. Add newones and clean up later when you are sure.

Page 57: From dev to ops and beyond - getting it done

THANK YOU!

Page 58: From dev to ops and beyond - getting it done

QUESTIONS?Get in touch

Twitter: @_ _edorianG+: Volker DuschIRC: edorianMail: [email protected]

Check those things out:

Facebook: https://www.facebook.com/Engineering?sk=notesEtsy: http://codeascraft.com/

Page 59: From dev to ops and beyond - getting it done