.
@tweetingsherry
PETS AND PANDAS
😸🐶🐰 🐼 🐼 🐼
.
@tweetingsherry
Chris Sherry
Senior Software Engineer @passengerteam
@passengerteam
.
@tweetingsherry
Chris Sherry
Senior Software Engineer @passengerteam
@passengerteam
.
@tweetingsherry
discoverpassenger.com
@passengerteam
.
@tweetingsherry
SERVERS
.
@tweetingsherry
Cattle
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
Cattle
🔟 Assigned Numbers
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
Cattle
🔟 Assigned Numbers
♊ Are usually identical
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
Cattle
🔟 Assigned Numbers
♊ Are usually identical
💰 You need more, you buy
more
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
Cattle
🔟 Assigned Numbers
♊ Are usually identical
💰 You need more, you buy
more
🔫 Replaced when not in
good health
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
PETS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
📛 Have names
PETS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
📛 Have names
✨ Unique, special
PETS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
📛 Have names
✨ Unique, special
⏳ Change over time
PETS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
📛 Have names
✨ Unique, special
⏳ Change over time
🚑 Require bespoke care
PETS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
📛 Have names
✨ Unique, special
⏳ Change over time
🚑 Require bespoke care
❤ Kept alive when they are ill
PETS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
📛 Have names
✨ Unique, special
⏳ Change over time
🚑 Bespoke care
❤ Kept alive when they are ill
Pandas
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
📹 High profile media coverage
.
@tweetingsherry
Pet PROBLEMS
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
24/7
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry@tweetingsherry @wearebase @passengerteam
.
@tweetingsherry@tweetingsherry @wearebase @passengerteam
CHALLENGE ACCEPTED
.
@tweetingsherry
.
@tweetingsherry
$ ssh user@host -vvvvvvvvv
$ curl <url> -vvvvvvvvvvvv
$ ping 1.2.3.4
$ nmap
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
I HAVE NO MEMORY OF THIS PLACE
.
@tweetingsherry
177 cd /etc/nginx/sites-enabled/
178 ll
179 cd ..
180 cd sites-available/
181 ll
182 vim ~/.ssh/authorized_keys
183 cat /root/.ssh/
184 cat /root/.ssh/authorized_keys
185 history|less
$ history|less
.
@tweetingsherry
101 tail -f /opt/logs/nginx-error.log
102 vim /etc/nginx/sites-enabled/blog.conf
...
185 history|less
$ history|less
.
@tweetingsherry
101 tail -f /opt/logs/nginx-error.log
102 vim /etc/nginx/sites-enabled/blog.conf
...
185 history|less
$ history|less
.
@tweetingsherry
93 service nginx restart
94 service php7.0-fpm
95 service php7.0-fpm restart
...
185 history|less
$ history|less
.
@tweetingsherry
.
@tweetingsherry
93 service nginx restart
94 service php7.0-fpm
95 service php7.0-fpm restart
$ history|less
$ !93
$ service nginx restart
.
@tweetingsherry
$ ls -l /home
.
@tweetingsherry
drwxrwxrwt root root root
drwxr-xr-x+ web web web

drwxr-xr-x+ admin sudoers admin
$ sudo su web
$ ls -l /home
.
@tweetingsherry https://medium.com/@adminstoolbox/debugging-using-strace-efda7d65be1d
.
@tweetingsherry https://medium.com/@adminstoolbox/debugging-using-strace-efda7d65be1d
.
@tweetingsherry
$ pidof nginx
.
@tweetingsherry
$ pidof nginx
20306 20304
.
@tweetingsherry
$ pidof nginx
20306 20304
$ strace -p 20304 -p 20306 -f
.
@tweetingsherry
$ pidof nginx
20306 20304
$ strace -p 20304 -p 20306 -f
inet_addr("81.27.88.19")
"GET / HTTP/1.1rn
stat(“/var/www/site.com/current/web/index.php"
writev(4, [{"HTTP/1.1 301 Moved Permanentlyrn"
.
@tweetingsherry
$ pidof php-fpm
20434 20435
.
@tweetingsherry
$ pidof php-fpm
20434 20435
$ strace -p 20304 -p 20306 -f
.
@tweetingsherry
$ pidof php-fpm
20434 20435
$ strace -p 20304 -p 20306 -f
access("/var/www/config/prod.php", F_OK) = 0
access("/var/www/config/clients/operator.php",
F_OK) = -1 ENOENT (No such file or directory)
.
@tweetingsherry
$ strace php cron.php
.
@tweetingsherry
$ strace php cron.php
open("/etc/php/7.0/cli/php.ini", O_RDONLY) = 3
open("/etc/php/7.0/cli/conf.d/10-pdo.ini", O_RDONLY) = 3
open("/var/log/newrelic/php_agent.log", O_WRONLY|O_CREAT|
O_APPEND, 0666) = 3
connect(4, {sa_family=AF_LOCAL, sun_path="/
tmp/.newrelic.sock"}, 22) = 0
.
@tweetingsherry
$ top
$ htop
.
@tweetingsherry
$ lsof
sshd 985 root 6u TCP *:22
mongod 988 mongodb 6u TCP 127.0.0.1:27017
php-fpm7. 10546 root 8u TCP 127.0.0.1:9000
nginx 20304 root 8u TCP *:80
nginx 20304 root 9u TCP *:443
.
@tweetingsherry
NOT ENOUGH SPACE
.
@tweetingsherry
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 4.0K 487M 1% /dev
tmpfs 100M 376K 100M 1% /run
/dev/vda1 100G 100G 4.0B 100% /
.
@tweetingsherry
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 4.0K 487M 1% /dev
tmpfs 100M 376K 100M 1% /run
/dev/vda1 100G 100G 4.0B 100% /
.
@tweetingsherry
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 4.0K 487M 1% /dev
tmpfs 100M 376K 100M 1% /run
/dev/vda1 100G 100G 4.0B 100% /
$ rm -rf /var/cache/apt/archives
$ rm -rf /var/cache
$ ls -l /tmp
$ ls -l /var/log
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
$ fallocate -l 4G /swapfile
$ chmod 600 /swapfile
$ mkswap /swapfile
$ swapon /swapfile
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
MariaDB > show variables like
“max_connections”
+—————————————————+———————+
| Variable_name | Value |
+—————————————————+———————+

| max_connections | 151 |
+—————————————————+———————+
.
@tweetingsherry
MariaDB >
set global max_connections = 200;
+—————————————————+———————+
| Variable_name | Value |
+—————————————————+———————+

| max_connections | 200 |
+—————————————————+———————+
.
@tweetingsherry
vim /etc/mysql/conf.d/mysql.cnf
[mysql]
max_connections = 200
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea@tweetingsherry
.
@tweetingsherry https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea@tweetingsherry
.
@tweetingsherry
mysql>
SET GLOBAL slow_query_log = ‘ON’;
.
@tweetingsherry
mysql>
SET GLOBAL slow_query_log = ‘ON’;
⚠
DO NOT LEAVE THIS
RUNNING IN PRODUCTION!
.
@tweetingsherry
mysql>
SET GLOBAL slow_query_log = ‘ON’;
/var/lib/mysql/production-slow.log
.
@tweetingsherry
mysql>
SET GLOBAL slow_query_log = ‘ON’;
/var/lib/mysql/production-slow.log
.
@tweetingsherry
mysql>
SET GLOBAL
log_queries_not_using_indexes
= ‘ON’;
.
@tweetingsherry
Reading mysql slow query log from /var/lib/mysql/
production-slow.log
Count:414 Time: 28.98s Lock: 0.00s Rows_sent 1.0,
Rows_examined: 1456 Rows_affected: 0
Count:1 Time: 2.00s Lock: 0.00s Rows_sent 1.0,
Rows_examined: 1 Rows_affected: 0
$ mysqldumpslow -a production-slow.log
.
@tweetingsherry
INDEX ALL THE THINGS
.
@tweetingsherry
Indexes
$ mysql> desc users;
.
@tweetingsherry
Indexes
$ mysql> desc users;
.
@tweetingsherry
Cardinality
$ mysql> show index from users;
.
@tweetingsherry
Cardinality
$ mysql> show index from users;
.
@tweetingsherry
QUERY ORDER
$ mysql> explain select first_name from user_profiles
where date_of_birth < “2018—01-01” and first_name like “chris%”
.
@tweetingsherry
QUERY ORDER
$ mysql> explain select first_name from user_profiles
where date_of_birth < “2018—01-01” and first_name like “chris%”
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry https://medium.com/@Jay_Jamison/pets-cattle-and-pandas-30aad4a0cdea
.
@tweetingsherry
DISCOUNT CODE: DAVE15
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
.
@tweetingsherry
git reset —hard ~100
git branch -D feature/work-in-progress
.
@tweetingsherry
GIF OF REFLOG
.
@tweetingsherry
GIF OF REFLOG
.
@tweetingsherry
GIF OF REFLOG
.
@tweetingsherry
GIF OF REFLOG
.
@tweetingsherry
git habits
.
@tweetingsherry
git habits
git commit -am “message”
.
@tweetingsherry
git habits
git commit -am “message”
git add .
.
@tweetingsherry
git habits
git commit -am “message”
git add .
git commit
.
@tweetingsherry
git habits
git commit -am “message”
git add .
git commit
git add -p (--pick)
.
@tweetingsherry
git habits
git commit -am “message”
git add .
git commit
git add -p (--pick)
git push --force-with-lease
.
@tweetingsherry
git habits
git commit -am “message”
git add .
git commit
git add -p (--pick)
git push --force-with-lease
git merge --no-commit

Pets and Pandas.