0
hi
Hello.Hi everyone.
My name is Chris Wanstrath. I go by @defunkt online.
inside   githubAnd today I’m going to talk about GitHub.
inside   githubThat’s me.
GitHub is what we like to call “social coding.”
You can see what your friends are doing from your dashboard or news feed
Everyone has a profile showing off their code and activity
And you can do things like leave comments on commits.
But it wasn’t always like this.
Originally we just wanted to make a git hosting site.In fact, that was the first tagline.
git repository hostinggit repository hosting.That’s what we wanted to do: give us and our friends a place to share git rep...
a brief  historylet’s start with a brief history
It’s not easy to setup a git repository. It never was.But back in 2007 I really wanted to.
I had seen Torvalds’ talk on YouTube about git.But it wasn’t really about git - it was more about distributed version cont...
CVS                                         is stupidBut when Torvalds says “CVS is stupid”
and so are                                                         you“and so are you,” the natural reaction for me is...
To start learning git.
At the time the biggest and best free hosting site was repo.or.cz.
Right after I had seen the Torvalds video, the god project was posted up on repo.or.czI was interested in the project so I...
Namely this guy, Tom Preston-Werner.Seen here in his famous “I put ketchup on my ketchup” shirt.
I managed to make a few contributions to god before realizing that repo.or.cz was not different.git was not different.Just...
This is what I always imagined.No rules. Project belongs to you, not the site. Share, fork, change - do what you want.Give...
So, we set off to create our own site.A git hub - learning, code hosting, etc.
We started with the code browsing and commit viewing...
But once we added the current version of the dashboard, we knew this was different.
And eventually “git repository hosting” gave way to “social coding”
Unleash Your Code                               Join 500,000 coders with                              over 1,500,000 repos...
2007 octoberThe first commit was on a Friday night in October, around 10pm.
2008 januaryWe launched the beta in January at Steff’s on 2nd street in San Francisco’s SOMA district.The first non-github ...
2008 aprilA few short months after that we launched to the public.
Along the way we managed to pick up Scott Chacon, our VP of R&D
Tekkub, our level 80 support druid
Melissa Severini, who keeps us all in check
Kyle Neath, who makes the site pretty
Ryan Tomayko, who helps keep the site running smoothly.
Zach Holman, head of enterprise
Rick Olson, Rails extraordinaire
Eston Bond, Design Generalissimo
Corey Donohoe, Director of Shipology
And Brian Lopez, our bleeding edge cowboy
Oh yeah, and the other founders: PJ and Tom.
github.comThat’s where we’re at today.So let’s talk about the technical details of the website: github.com
.com as opposed to fi, which I’m not going to get into today.You’ll have to invite PJ out if you want to hear about that.
We also have a store
A job board
And do git training
the web siteAs everyone knows, a web “site” is really a bunch of different components.Some of them generate and deliver HT...
rails                        #GitHub.com, Gist, etc                            1
resque                                                             #Background processing, 50ish different job types curre...
smoke                                     #All git calls happen over the wire                                         3
utils                                             #Exception logging, stats, helper apps, etc                             ...
railsWe use Ruby on Rails 2.2.2 as our web framework.It’s kept up to date with all the security patches and includes custo...
railsGitHub is about 20,000 lines of Rails code, not counting Rails itself, plugins, or gems.
We found out Rails was moving to GitHub in March 2008, after we had reached out tothem and they had turned us down.So it w...
rails pluginsWe currently have 27 Rails plugins installed, and that number is always changing.
shopify / active_merchant
lgn21st / s3_swf_upload
technoweenie /serialized_attributes
query_trace
query_analyzer
rubygemsGitHub depends on about 50 RubyGems
albino
ar-extensions
aws-s3
faker
faraday
github-markup
rdiscount
jekyll
gollum
redis-rb
rackOne of the big features in Rails 2.3 is Rack support.
We badly wanted this, but didn’t want to invest the time upgrading.So using a few open source libraries we’ve wrapped our ...
Now we can use awesome Rack middleware like Rack::Bug in GitHub
Coders created and submitted dozens of Rack middleware for the Coderack competition last year.I was a judge so I got the s...
nerdEd / rack-validate
webficient / rack-tidy
talison / rack-mobile-detectsets the X_MOBILE_DEVICE header to the mobile device, ifrecognized
unicornWe use unicorn as our application server- master / worker- 16 workers- preforking
unicorn- instant restart after kill- hard 30s request timeouts- control ram growth
unicorn- 0 downtime deploys- protects against bad rails startup- migrations handled old fashioned way
nginxFor serving static content and slow clients, we use nginxnginx is pretty much the greatest http server everit’s simpl...
nginxLimit ZoneLimit simultaneous connections from a client
nginxLimit RequestsLimit frequency of connections from a clientAnti-DDOS
nginxI see many people using Rack to do what the Limit modules do.Don’t.
nginxmemcachedmemcached supportcan serve directly from memcached
nginxPush Modulecomet!
gitThe next major part of GitHub is git
gritWe wrote an open source library called Gritwhich lets us use git from Ruby
mojombo / grityou can get it hereit originally shelled out to git and just parsed the responses.which worked well for a lo...
gritFile.read()Eventually we realized, however, that File.read() can be 100 times faster
gritsystem()Than shelling out
One of the first things Scott worked on was rewriting the core parts of Gritto be pure RubyBasically a Ruby implementation ...
mojombo / gritAnd that’s what we run now
smokeKinda.Eventually we needed to move of our git repositories off of our web serversToday our HTTP servers are distinct ...
smoke“Grit in the cloud”Instead of reading and writing from the disk, Grit makes Smoke callsThe reading and writing then h...
bert-rpcRather than use Protocol Buffers or Thrift or JSON-RPC, Smoke uses BERT-RPC
bert-rpcbert : erlang ::json : javascriptBERT is an erlang-based protocolBERT-RPC is really great at dealing with large bi...
bert-rpcwe have four file servers, each running bert-rpc serversour front ends and job queue make RPC calls to the backend ...
mojombo / bertrpcYou can grab bert-rpc on GitHub
mojombo / bertOr if you just want to play with BERT
chimneyWe have a proprietary library called chimneyIt routes the smoke. I know, don’t blame me.
chimneyAll user routes are kept in RedisChimney is how our BERT-RPC clients know which server to hitIt falls back to a loc...
chimneyIt can also be told a backend is down.Optimized for connection refused but in reality that wasn’t the real problem ...
proxymachineAll anonymous git clones hit the front end machinesthe git-daemon connects to proxymachine, which uses chimney...
mojombo / proxymachineproxymachine can be used to proxy any kind of tcp connectionopen source
sshSometimes you need to access a repository over sshIn those instances, you ssh to an fe and we tunnel your connection to...
node.js
node.jsdownloads
node.jsdownloadshttp => https <img>
node.jsdownloadshttp => https <img>event streams
hubot
jobsWe do a lot of work in the background at GitHub
resqueCurrently we use a system called Resque.
defunkt / resqueYou can grab it on GitHub
resque-   dealing with pushes-   web hooks-   creating events in the database-   generating GitHub Pages-   clearing & war...
queuesIn Resque, a queue is used as both a priority and a localization techniqueBy localization I mean, “where your worker...
queuescritical,high,lowthese three run on our front end serversResque processes them in this order
queuespageGitHub Pages are generated on their own machine using the `page` queue
queuesarchiveAnd tarball and zip downloads are created on the fly using the `archive` queueon our archiving machines
searchOn GitHub, you can search code, repositories, and people
solrSolr is basically an HTTP interface on top of Lucene. This makes it pretty simpleto use in your code.We use solr becau...
Here I am searching for my name in source code
solrWe’ve had some problems making it stable but luckily the guys at Pivotalhave given us some tipsLike bumping the Java h...
databaseOur database story is pretty uninteresting
mysqlWe use mysql 5
master / slaveAll reads and writes go to the masterWe use the slave for backups and failover
cachingOn the site we do a ton of cachingusing memcached
fragmentsWe cache chunks of HTML all overUsually they are invalidated by some action
fragmentsFormerly we invalidated most of our fragments using a generation scheme,where you put a number into a bunch of re...
fragmentsBut we had high cache eviction due to low ram and hardware constraints, and foundthat scheme did more harm than g...
pageWe cache entire pages using nginx’s memcached moduleLots of HTML, but also other data which gets hit a lot and changes...
page- network graph json- participation graph dataAlways looking to stick more into page caches
objectWe do basic object caching of ActiveRecord objects such asrepositories and users all over the placeCaches are invali...
associationsWe also cache associations as arrays of IDsGrab the array, then do a get_multi on its contents to get a list o...
walkerWe also have a proprietary caching library called Walker
walkerIt originally walked trees and cached them when someone pushedBut now it caches everything related to git:
walker-   commits-   diffs-   commit listing-   branches-   tags-   everything
Every git-related page load hits Walker a lot
walkerFor most big apps, you need to write a caching layerthat knows your business domainGeneric, catch-all caching librar...
eventsAn example of this is our events system
This is one fragment
Each of these is a fragment
They’re also cached as objects
As well as a list of ids
And that’s just for the dashboard...
optimizationsSo what other optimizations have we done
asset serversWell we do the common trick of serving assets from multiple subdomains
asset serversassets0.github.comassets1.github.comand so forth
sha asset idInstead of using timestamps for asset ids, which may end up hitting the diskmultiple times on each request, we...
sha asset id/css/bundle.css?197d742e9fdec3f7/js/bundle.js?197d742e9fdec3f7Now simple code changes won’t force everyone to ...
bundlingFor bundling itself, we use
bundlingyui’s compressor for css and
bundlinggoogle’s closure compiler for javascriptwe don’t use the most aggressive setting because it means changingyour jav...
scripty 301Again, for most of these tricks you need to really payattention to your app.One example is scriptaculous’ wiki
scripty 301When we changed our wiki URL structure, we setup dynamic 301 redirectsfor the old urls.Scriptaculous’ old wiki ...
ajax loadingWe also load data in via ajax in many places.Sometimes a piece of information will just take too long to retri...
If Walker sees that it doesn’t have all the information it needs, it kicks off a jobto stick that information in memcached.
We then periodically hit a URL which checks if the information is in memcached or not.If it is, we get it and rewrite the ...
We use this same trick on the Network Graph
Fork Queue
ajax loadingand anywhere else it makes sense.
comet loadingvery soon this will all be comet, though
monitoringwhat do we use for monitoring?
nagiosOur support team monitors the health of our machines and coreservices using nagios.I don’t really touch the thing.
Here’s a screenshot from my IE browser, complete with the ICQ plugin
resque webWe monitor our queue using Resque’s included Sinatra app
haystackWe use an in-house app called Haystack to monitor arbitrary information,tracked as JSON.
Here’s an example of Haystack’s “exceptions” view
collectdWe also use collectd to monitor load, RAM usage, CPU usage, and otherapp-related metrics
pingdompingdom sends us SMSes when the site is downit’s nice
tendertender is what we use for customer support
it works incredibly well, and they’re constantly improving it
testingOur testing setup is pretty standard
test unitWe mostly use Ruby’s test/unit.We’ve experimented with other libraries including test/spec, shoulda, and RSpec, b...
git fixturesAs many of our fixtures are git repositories, we specify in the test what shawe expect to be the HEAD of that fix...
machinistWe use machinist for our fixtures
notahat / machinist
running_manGives us setup_onceUse it to cache machinist fixtures on a per-test-class basis
technoweenie / running_man
ci joeWe use ci joe, a continuous integration server, to run on tests after each push.He then notifies us if the tests fail.
defunkt / cijoeYou can grab him at github
stagingWe also always deploy the current branch to stagingThis means you can be working on your branch, someone else can b...
security
github.com/securityhaving a security page really helps
security@github.comwe get weekly emails to our security email (that people find on the security page)and people are always ...
regular auditsif you can, find a security consultant to poke your site for XSS vulnerabilitieshaving your target audience b...
24/7 monitoring24/7 monitoring is cool too
backupsbackups are incredibly importantdon’t just make backups: ensure you can restore them, as well
sqlwe keep nightly, off-site backups of our sql databases
gitand the same for all our git repositories
the future
svn
pull requests
organizations
...and more
Questions?thanks for coming
Thanks.thanks for coming
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
Upcoming SlideShare
Loading in...5
×

Inside GitHub with Chris Wanstrath

20,652

Published on

"Inside GitHub - A high level overview of the stack and the glue"

Published in: Technology
5 Comments
92 Likes
Statistics
Notes
No Downloads
Views
Total Views
20,652
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
427
Comments
5
Likes
92
Embeds 0
No embeds

No notes for slide

Transcript of "Inside GitHub with Chris Wanstrath"

  1. 1. hi
  2. 2. Hello.Hi everyone.
  3. 3. My name is Chris Wanstrath. I go by @defunkt online.
  4. 4. inside githubAnd today I’m going to talk about GitHub.
  5. 5. inside githubThat’s me.
  6. 6. GitHub is what we like to call “social coding.”
  7. 7. You can see what your friends are doing from your dashboard or news feed
  8. 8. Everyone has a profile showing off their code and activity
  9. 9. And you can do things like leave comments on commits.
  10. 10. But it wasn’t always like this.
  11. 11. Originally we just wanted to make a git hosting site.In fact, that was the first tagline.
  12. 12. git repository hostinggit repository hosting.That’s what we wanted to do: give us and our friends a place to share git repositories.
  13. 13. a brief historylet’s start with a brief history
  14. 14. It’s not easy to setup a git repository. It never was.But back in 2007 I really wanted to.
  15. 15. I had seen Torvalds’ talk on YouTube about git.But it wasn’t really about git - it was more about distributed version control.It answered many of my questions and clarified DVCS ideas.I still wasn’t sold on the whole idea, and I had no idea what it was good for.
  16. 16. CVS is stupidBut when Torvalds says “CVS is stupid”
  17. 17. and so are you“and so are you,” the natural reaction for me is...
  18. 18. To start learning git.
  19. 19. At the time the biggest and best free hosting site was repo.or.cz.
  20. 20. Right after I had seen the Torvalds video, the god project was posted up on repo.or.czI was interested in the project so I finally got a chance to try it out with some other people.
  21. 21. Namely this guy, Tom Preston-Werner.Seen here in his famous “I put ketchup on my ketchup” shirt.
  22. 22. I managed to make a few contributions to god before realizing that repo.or.cz was not different.git was not different.Just more of the same - centralized, inflexible code hosting.
  23. 23. This is what I always imagined.No rules. Project belongs to you, not the site. Share, fork, change - do what you want.Give people tools and get out of their way. Less ceremony.
  24. 24. So, we set off to create our own site.A git hub - learning, code hosting, etc.
  25. 25. We started with the code browsing and commit viewing...
  26. 26. But once we added the current version of the dashboard, we knew this was different.
  27. 27. And eventually “git repository hosting” gave way to “social coding”
  28. 28. Unleash Your Code Join 500,000 coders with over 1,500,000 repositoriesWhat’s special about GitHub is that people use the site in spite of git.Many git haters use the site because of what it is - more than a place to hostgit repositories, but a place to share code with others.
  29. 29. 2007 octoberThe first commit was on a Friday night in October, around 10pm.
  30. 30. 2008 januaryWe launched the beta in January at Steff’s on 2nd street in San Francisco’s SOMA district.The first non-github user was wycats, and the first non-github project was merb-core.They wanted to use the site for their refactoring and 0.9 branch.
  31. 31. 2008 aprilA few short months after that we launched to the public.
  32. 32. Along the way we managed to pick up Scott Chacon, our VP of R&D
  33. 33. Tekkub, our level 80 support druid
  34. 34. Melissa Severini, who keeps us all in check
  35. 35. Kyle Neath, who makes the site pretty
  36. 36. Ryan Tomayko, who helps keep the site running smoothly.
  37. 37. Zach Holman, head of enterprise
  38. 38. Rick Olson, Rails extraordinaire
  39. 39. Eston Bond, Design Generalissimo
  40. 40. Corey Donohoe, Director of Shipology
  41. 41. And Brian Lopez, our bleeding edge cowboy
  42. 42. Oh yeah, and the other founders: PJ and Tom.
  43. 43. github.comThat’s where we’re at today.So let’s talk about the technical details of the website: github.com
  44. 44. .com as opposed to fi, which I’m not going to get into today.You’ll have to invite PJ out if you want to hear about that.
  45. 45. We also have a store
  46. 46. A job board
  47. 47. And do git training
  48. 48. the web siteAs everyone knows, a web “site” is really a bunch of different components.Some of them generate and deliver HTML to you, but most of them don’t.Our site consists of four major code “frameworks” or “apps”
  49. 49. rails #GitHub.com, Gist, etc 1
  50. 50. resque #Background processing, 50ish different job types currently 2
  51. 51. smoke #All git calls happen over the wire 3
  52. 52. utils #Exception logging, stats, helper apps, etc 4
  53. 53. railsWe use Ruby on Rails 2.2.2 as our web framework.It’s kept up to date with all the security patches and includes custom patches we’ve addedourselves, as well as patches we’ve cherry-picked from more recent versions of Rails.
  54. 54. railsGitHub is about 20,000 lines of Rails code, not counting Rails itself, plugins, or gems.
  55. 55. We found out Rails was moving to GitHub in March 2008, after we had reached out tothem and they had turned us down.So it was a bit of a surprise.
  56. 56. rails pluginsWe currently have 27 Rails plugins installed, and that number is always changing.
  57. 57. shopify / active_merchant
  58. 58. lgn21st / s3_swf_upload
  59. 59. technoweenie /serialized_attributes
  60. 60. query_trace
  61. 61. query_analyzer
  62. 62. rubygemsGitHub depends on about 50 RubyGems
  63. 63. albino
  64. 64. ar-extensions
  65. 65. aws-s3
  66. 66. faker
  67. 67. faraday
  68. 68. github-markup
  69. 69. rdiscount
  70. 70. jekyll
  71. 71. gollum
  72. 72. redis-rb
  73. 73. rackOne of the big features in Rails 2.3 is Rack support.
  74. 74. We badly wanted this, but didn’t want to invest the time upgrading.So using a few open source libraries we’ve wrapped our Rails 2.2.2 instance in Rack.
  75. 75. Now we can use awesome Rack middleware like Rack::Bug in GitHub
  76. 76. Coders created and submitted dozens of Rack middleware for the Coderack competition last year.I was a judge so I got the see the submissions already. Some of my favoritewere
  77. 77. nerdEd / rack-validate
  78. 78. webficient / rack-tidy
  79. 79. talison / rack-mobile-detectsets the X_MOBILE_DEVICE header to the mobile device, ifrecognized
  80. 80. unicornWe use unicorn as our application server- master / worker- 16 workers- preforking
  81. 81. unicorn- instant restart after kill- hard 30s request timeouts- control ram growth
  82. 82. unicorn- 0 downtime deploys- protects against bad rails startup- migrations handled old fashioned way
  83. 83. nginxFor serving static content and slow clients, we use nginxnginx is pretty much the greatest http server everit’s simple, fast, and has a great module system
  84. 84. nginxLimit ZoneLimit simultaneous connections from a client
  85. 85. nginxLimit RequestsLimit frequency of connections from a clientAnti-DDOS
  86. 86. nginxI see many people using Rack to do what the Limit modules do.Don’t.
  87. 87. nginxmemcachedmemcached supportcan serve directly from memcached
  88. 88. nginxPush Modulecomet!
  89. 89. gitThe next major part of GitHub is git
  90. 90. gritWe wrote an open source library called Gritwhich lets us use git from Ruby
  91. 91. mojombo / grityou can get it hereit originally shelled out to git and just parsed the responses.which worked well for a long time.
  92. 92. gritFile.read()Eventually we realized, however, that File.read() can be 100 times faster
  93. 93. gritsystem()Than shelling out
  94. 94. One of the first things Scott worked on was rewriting the core parts of Gritto be pure RubyBasically a Ruby implementation of Git
  95. 95. mojombo / gritAnd that’s what we run now
  96. 96. smokeKinda.Eventually we needed to move of our git repositories off of our web serversToday our HTTP servers are distinct from our git servers. The two communicate using smoke
  97. 97. smoke“Grit in the cloud”Instead of reading and writing from the disk, Grit makes Smoke callsThe reading and writing then happens on our file servers
  98. 98. bert-rpcRather than use Protocol Buffers or Thrift or JSON-RPC, Smoke uses BERT-RPC
  99. 99. bert-rpcbert : erlang ::json : javascriptBERT is an erlang-based protocolBERT-RPC is really great at dealing with large binariesWhich is a lot of what we do
  100. 100. bert-rpcwe have four file servers, each running bert-rpc serversour front ends and job queue make RPC calls to the backend servers
  101. 101. mojombo / bertrpcYou can grab bert-rpc on GitHub
  102. 102. mojombo / bertOr if you just want to play with BERT
  103. 103. chimneyWe have a proprietary library called chimneyIt routes the smoke. I know, don’t blame me.
  104. 104. chimneyAll user routes are kept in RedisChimney is how our BERT-RPC clients know which server to hitIt falls back to a local cache and auto-detection if Redis is down
  105. 105. chimneyIt can also be told a backend is down.Optimized for connection refused but in reality that wasn’t the real problem - timeouts were
  106. 106. proxymachineAll anonymous git clones hit the front end machinesthe git-daemon connects to proxymachine, which uses chimney to proxy yourconnection between the front end machine and the back end machine (which holdsthe actual git repository)very fast, transparent to you
  107. 107. mojombo / proxymachineproxymachine can be used to proxy any kind of tcp connectionopen source
  108. 108. sshSometimes you need to access a repository over sshIn those instances, you ssh to an fe and we tunnel your connection tothe appropriate backendTo figure that out we use chimney
  109. 109. node.js
  110. 110. node.jsdownloads
  111. 111. node.jsdownloadshttp => https <img>
  112. 112. node.jsdownloadshttp => https <img>event streams
  113. 113. hubot
  114. 114. jobsWe do a lot of work in the background at GitHub
  115. 115. resqueCurrently we use a system called Resque.
  116. 116. defunkt / resqueYou can grab it on GitHub
  117. 117. resque- dealing with pushes- web hooks- creating events in the database- generating GitHub Pages- clearing & warmingcaches- search indexing
  118. 118. queuesIn Resque, a queue is used as both a priority and a localization techniqueBy localization I mean, “where your workers live”
  119. 119. queuescritical,high,lowthese three run on our front end serversResque processes them in this order
  120. 120. queuespageGitHub Pages are generated on their own machine using the `page` queue
  121. 121. queuesarchiveAnd tarball and zip downloads are created on the fly using the `archive` queueon our archiving machines
  122. 122. searchOn GitHub, you can search code, repositories, and people
  123. 123. solrSolr is basically an HTTP interface on top of Lucene. This makes it pretty simpleto use in your code.We use solr because of its ability to incrementally add documents toan index.
  124. 124. Here I am searching for my name in source code
  125. 125. solrWe’ve had some problems making it stable but luckily the guys at Pivotalhave given us some tipsLike bumping the Java heap size.Whatever that means
  126. 126. databaseOur database story is pretty uninteresting
  127. 127. mysqlWe use mysql 5
  128. 128. master / slaveAll reads and writes go to the masterWe use the slave for backups and failover
  129. 129. cachingOn the site we do a ton of cachingusing memcached
  130. 130. fragmentsWe cache chunks of HTML all overUsually they are invalidated by some action
  131. 131. fragmentsFormerly we invalidated most of our fragments using a generation scheme,where you put a number into a bunch of related keys and increment itwhen you want all those caches to be missed (thus creating new cacheentries with fresh data)
  132. 132. fragmentsBut we had high cache eviction due to low ram and hardware constraints, and foundthat scheme did more harm than good.We also noticed some cached data we wanted to remain forever was being evicted dueto the slabs with generational keys filling up fast
  133. 133. pageWe cache entire pages using nginx’s memcached moduleLots of HTML, but also other data which gets hit a lot and changes rarely:
  134. 134. page- network graph json- participation graph dataAlways looking to stick more into page caches
  135. 135. objectWe do basic object caching of ActiveRecord objects such asrepositories and users all over the placeCaches are invalidated whenever the objects are saved
  136. 136. associationsWe also cache associations as arrays of IDsGrab the array, then do a get_multi on its contents to get a list of objectsThat way we don’t have to worry about caching stale objects
  137. 137. walkerWe also have a proprietary caching library called Walker
  138. 138. walkerIt originally walked trees and cached them when someone pushedBut now it caches everything related to git:
  139. 139. walker- commits- diffs- commit listing- branches- tags- everything
  140. 140. Every git-related page load hits Walker a lot
  141. 141. walkerFor most big apps, you need to write a caching layerthat knows your business domainGeneric, catch-all caching libraries probably won’t do
  142. 142. eventsAn example of this is our events system
  143. 143. This is one fragment
  144. 144. Each of these is a fragment
  145. 145. They’re also cached as objects
  146. 146. As well as a list of ids
  147. 147. And that’s just for the dashboard...
  148. 148. optimizationsSo what other optimizations have we done
  149. 149. asset serversWell we do the common trick of serving assets from multiple subdomains
  150. 150. asset serversassets0.github.comassets1.github.comand so forth
  151. 151. sha asset idInstead of using timestamps for asset ids, which may end up hitting the diskmultiple times on each request, we set the asset id to be the sha of the last commitwhich modified a javascript or css file
  152. 152. sha asset id/css/bundle.css?197d742e9fdec3f7/js/bundle.js?197d742e9fdec3f7Now simple code changes won’t force everyone to re-download the css or js bundles
  153. 153. bundlingFor bundling itself, we use
  154. 154. bundlingyui’s compressor for css and
  155. 155. bundlinggoogle’s closure compiler for javascriptwe don’t use the most aggressive setting because it means changingyour javascript to appease the compression gods,which we haven’t committed to yet
  156. 156. scripty 301Again, for most of these tricks you need to really payattention to your app.One example is scriptaculous’ wiki
  157. 157. scripty 301When we changed our wiki URL structure, we setup dynamic 301 redirectsfor the old urls.Scriptaculous’ old wiki was getting hit so much we put the redirect into nginx itself -this took strain off our web app and made the redirects happen almost instantly
  158. 158. ajax loadingWe also load data in via ajax in many places.Sometimes a piece of information will just take too long to retrieveIn those instances, we usually load it in with ajax
  159. 159. If Walker sees that it doesn’t have all the information it needs, it kicks off a jobto stick that information in memcached.
  160. 160. We then periodically hit a URL which checks if the information is in memcached or not.If it is, we get it and rewrite the page with the new information.
  161. 161. We use this same trick on the Network Graph
  162. 162. Fork Queue
  163. 163. ajax loadingand anywhere else it makes sense.
  164. 164. comet loadingvery soon this will all be comet, though
  165. 165. monitoringwhat do we use for monitoring?
  166. 166. nagiosOur support team monitors the health of our machines and coreservices using nagios.I don’t really touch the thing.
  167. 167. Here’s a screenshot from my IE browser, complete with the ICQ plugin
  168. 168. resque webWe monitor our queue using Resque’s included Sinatra app
  169. 169. haystackWe use an in-house app called Haystack to monitor arbitrary information,tracked as JSON.
  170. 170. Here’s an example of Haystack’s “exceptions” view
  171. 171. collectdWe also use collectd to monitor load, RAM usage, CPU usage, and otherapp-related metrics
  172. 172. pingdompingdom sends us SMSes when the site is downit’s nice
  173. 173. tendertender is what we use for customer support
  174. 174. it works incredibly well, and they’re constantly improving it
  175. 175. testingOur testing setup is pretty standard
  176. 176. test unitWe mostly use Ruby’s test/unit.We’ve experimented with other libraries including test/spec, shoulda, and RSpec, but in the endwe keep coming back to test/unit
  177. 177. git fixturesAs many of our fixtures are git repositories, we specify in the test what shawe expect to be the HEAD of that fixture.This means we can completely delete a git repository in one test, then have it back inpristine state in another. We plan to move all our fixtures to a similar git-system in the future.
  178. 178. machinistWe use machinist for our fixtures
  179. 179. notahat / machinist
  180. 180. running_manGives us setup_onceUse it to cache machinist fixtures on a per-test-class basis
  181. 181. technoweenie / running_man
  182. 182. ci joeWe use ci joe, a continuous integration server, to run on tests after each push.He then notifies us if the tests fail.
  183. 183. defunkt / cijoeYou can grab him at github
  184. 184. stagingWe also always deploy the current branch to stagingThis means you can be working on your branch, someone else can be working on theirs,and you don’t need to worry about reconciling the two to test out a featureOne of the best parts of Git
  185. 185. security
  186. 186. github.com/securityhaving a security page really helps
  187. 187. security@github.comwe get weekly emails to our security email (that people find on the security page)and people are always grateful when we can reassure them or a answer their question
  188. 188. regular auditsif you can, find a security consultant to poke your site for XSS vulnerabilitieshaving your target audience be developers helps, too
  189. 189. 24/7 monitoring24/7 monitoring is cool too
  190. 190. backupsbackups are incredibly importantdon’t just make backups: ensure you can restore them, as well
  191. 191. sqlwe keep nightly, off-site backups of our sql databases
  192. 192. gitand the same for all our git repositories
  193. 193. the future
  194. 194. svn
  195. 195. pull requests
  196. 196. organizations
  197. 197. ...and more
  198. 198. Questions?thanks for coming
  199. 199. Thanks.thanks for coming
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×