Posts

Showing posts from August, 2017

How to scale a website-My Approach

ELB  ---> Nginx servers ---> one Varnish Server  ---> Return if cache is found.

The problem I met is that /pop_service/{channel_id}/points will get burst hit by users. Thus, the load of the server will increase dramatically.

The solution to this problem is that ELB(Amazon Load Balancing Server) send matched requests to Nginx servers.

upstream backend { hash $request_uri consistent; server 104.207.149.81; server 45.63.83.59; } server { listen 80 default_server; listen [::]:80 default_server; location / { proxy_pass http://backend; } } Nginx servers with the above configuration have the ability to route requests based on request URI. AKA, the same URI gets redirects to the same server.


The config file of varnish is the following:


vcl 4.0; import directors; backend server1 { .host = "104.207.149.81"; .port = "80"; .probe = { .url = "/"; .timeout = 1s; .interv…

All the pitfalls I met in the first month

Pitfalls I met.

The first pitfall is regarding the environment. I have vagrant box (Homestead) installed on my Mac. However, the box crashes every one hour. I have no idea what went wrong. It is perhaps the God likes me that I fixed this environment issue the next day. I update my Mac to the newest version which solved this problem..  - -'

Twitch
I need an extra scope (channel_read) in order to view users stream key. Here is where things get tricky. Our website solely relies on third-party login. When user logins from Twitch again we lost the `view stream key` permission from the user.

Here is what we did to solve this problem. Firstly, I successfully convinced my team that we need to add `channel_read` scope in the config file so that we will always have this channel_read permission. However, things go south. Because this is an extra scope, every user of our website needs to re-login and re-auth in order to give us the permission. Our users pissed off, so we reverted this change i…