- Blaise Pascal: To show someone that he is wrong, we must notice from what side he views the thing, and tell him that from that side he views it correctly, but from another side he might view it wrongly.
- No one is offended at not seeing everything, but one does not like to be mistaken.
- People are generally better persuaded by the reasons by which they have themselves discovered than by those which have come into the mind of others.
- Point out the ways that they’re right first.
- If I immediately start to tell you all the ways in which you’re wrong, there’s no incentive for you to co-operate.
Linux utilities you might not know
``` shell $ cat data.txt | column -t -s ‘,’ #=> Columnizes stuff $ cal #=> Displays a calendar $ factor 12345 #=> Displays factors $ shred a.txt #=> Harder to retrieve rm ``
- Object Mother: A kind of class used in testing to help create examples that you use for testing.
- Canned objects that the Object Mother produces become familiar to the team, often invading even discussions with the users.
- Problem with OMs: Heavy coupling in that many tests will depend on the exact data in the mothers.
Unicorn vs. Puma vs. Passenger: which app server is right for you?
Amazon EC2 Instance Types
- SP: Always EBS so localized changes. You can change the volume/hard drive only.
- If you need to change the instance type (let’s say you need to scale vertically), you just stop the instance, change instance type to a bigger one (ex: T2 small to T2 medium), and start it again.
General Purpose Instances
- T2: General purpose instances. Burstable–this means that they have an ability to burst above the baseline with the use of burst CPU credits. Burst CPU credits accumulate at a set rate when they are idle, and they use CPU credits when they are active.
- Good choice if you don’t use the CPU often or consistently, but you need to burst.
- Use cases: Websites/web apps, dev envs, build servers, code repos, micro services, test/staging environments.
- M4. Latest generation of General purpose instances. Non-burstable. EBS (Elastic Block Store)-optimized.
- M3. Has SSD storage. Use cases: Small/mid-size databases, running back-end servers.
- C4. Highest performing processors. C4 Large: 3.75 GB memory, EBS storage, 500MB EBS bandwidth.
- C3. SSD-backed instance storage. C3 Large: 3.75 memory, 2 x 16 GB SSD.
- Use cases: Front-end fleets, web-servers, batch processing, distributed analytics, high performance science/engineering apps, ads, MMO gaming, video encoding.
- X1. Large-scale, enterprise class, and have the lowest price per GB RAM among AWS EC2 instance types. X1.32XLarge: 1,952 (!) GB, 2x1920 GB, 10000 EBS. Use cases: For running in-memory databases, big data processing engines like Apache Spark or Presto, high performance computing applications.
- R4. Better price/GB of RAM than R3. R4 large: 15.25 GB, networking performance, EBS-only SSD. Use cases: High performance databases, data mining, in-memory databases, Hadoop/Spark clusters.
- R3. Like R4, but SSD. Use cases: High performance databases, distributed memory caches.
T2 Large vs M4 Large
Configure Intance Details
- Always do terminate protection.
- Storage: General purpose unless many write/reads. IOPS: Input/output per second. Standard size: Free until 30.
- IAM security rule: port range. If not correct, you get Operation Timeout.
- Creating a new key pair. Every time you create a pem file.
- Checking the server: Monitoring via Cloudwatch.
- Changing the instance type: Just changing the VM type, not even starting it, will cost you something.
- Rails app server is the only thing that can access the RDS.
- Nginx security: via HTTP port 80 and HTTPS port 443.
- Pem file: Per VPC. THis is the
---BEGIN RSA PRIVATE KEY---file.
- Your machine has a private key.
- Each SP client has a private key that you get, and you send them your public key.
- Many pem files:
- Open elastic IP
- Create VPC (this will create a public private)
- Create NAT address for VPC which is the elastic IP that you created
- Create second subnet (2 private subnets)
- Create IAM security groups
- Create your servers: Suggested: RDS first since it takes times.
- Create your EC2. Bastion host and nginx server. Create 2 elastic IPs.
- Unprotected private key:
chmod 0400the pem file. This means the pem file is read-only.
- ssh -i path/to/pemfile [email protected] -vvv
- scp -i path/to/pemfile [email protected]/etc/.
- Then, from bastion, ssh into the nginx server, but also use the copied pemfile.
- apt-get update -y, apt-get upgrade
- TYPING TUTOR MODES!!!
- Change server time to their date.
- ntp: Network time protocol.
- nginx keepalive timeout: 65.
- sites-enabled, this is needed. nginx conf: /etc/nginx/nginx.conf
- restarting: configtest first.
- EC2 instances have no memory. Add swapfile.
- logrotate and monit.
- ln -s: symlink/alias
- crontab -e.
/var/log/: Nginx has automatic log rotate.
- In an nginx server:
tmpfolder is where things get stored.
- LTS: Long Term Support.