hackerwins/homepage-old

Slow Netlify response time

Closed this issue ยท 6 comments

Requests using Netlify have slow response time but calling directly to EC2 is fast.
We registered a proxy with Netlify to handle CORS. Compared to calling proxy directly:

Netlify Proxy call: 1.515sec

$ time curl 'https://yorkie.dev/api/api.Yorkie/ActivateClient' -H 'authority: yorkie.dev' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'x-user-agent: grpc-web-javascript/0.1' -H 'dnt: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36' -H 'content-type: application/grpc-web-text' -H 'access-control-allow-origin: *' -H 'accept: application/grpc-web-text' -H 'x-grpc-web: 1' -H 'access-control-allow-credentials: true' -H 'origin: https://yorkie.dev' -H 'sec-fetch-site: same-origin' -H 'sec-fetch-mode: cors' -H 'referer: https://yorkie.dev/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: ko,en-US;q=0.9,en;q=0.8' --data-binary 'AAAAACYSJGJlNmYyNTU5LWY0M2ItNDBkYTgtMTU4Ny0zNWQ2NGFhMmQzZA==' --compressed
AAAAAEAKJGJlNmYyNTU5LWY0M2ItNDBkYTgtMTU4Ny0zNWQ2NGFhMmQzZBIYNWUzOTY3M2E1YWI3MTc2NWYyNTNiYWE5gAAAAB5ncnBjLXN0YXR1czowDQpncnBjLW1lc3NhZ2U6DQo=curl 'https://yorkie.dev/api/api.Yorkie/ActivateClient' -H -H -H -H -H - 0.02s user 0.01s system 2% cpu 1.515 total

Direct call to EC2: 0.038sec

$ time curl 'http://ec2-52-78-24-195.ap-northeast-2.compute.amazonaws.com/api/api.Yorkie/ActivateClient' -H 'authority: yorkie.dev' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'x-user-agent: grpc-web-javascript/0.1' -H 'dnt: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36' -H 'content-type: application/grpc-web-text' -H 'access-control-allow-origin: *' -H 'accept: application/grpc-web-text' -H 'x-grpc-web: 1' -H 'access-control-allow-credentials: true' -H 'origin: https://yorkie.dev' -H 'sec-fetch-site: same-origin' -H 'sec-fetch-mode: cors' -H 'referer: https://yorkie.dev/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: ko,en-US;q=0.9,en;q=0.8' --data-binary 'AAAAACYSJGJlNmYyNTU5LWY0M2ItNDBkYTgtMTU4Ny0zNWQ2NGFhMmQzZA==' --compressed
curl -H 'authority: yorkie.dev' -H 'pragma: no-cache' -H -H -H 'dnt: 1' -H 0.01s user 0.01s system 41% cpu 0.038 total

CodeMirror examples also tend to be slow, which can be expensive to render.
Screen Shot 2020-02-05 at 7 40 27 AM

lqez commented

It's weird โ€” I thought that yorkie.dev only serves the static webpage stuff.

But it would be better to move the name server back to iwantmyname again.
Or if you have to keep using AWS deeper, Route53 could be a better option.

There was also an issue with server streams not working in the previous configuration.
So I configured docker-compose in EC2 as below.

[nginx] - [yorkie-team.github.io] # for serving static pages
        ใ„ด [grpc-web proxy, envoy] - [yorkie server] - [mongodb]  # for serving API

Call to nginx in EC2: 0.02sec

time curl 'http://ec2-52-78-24-195.ap-northeast-2.compute.amazonaws.com/api/api.Yorkie/ActivateClient' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'X-User-Agent: grpc-web-javascript/0.1' -H 'DNT: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36' -H 'Content-Type: application/grpc-web-text' -H 'Access-Control-Allow-Origin: *' -H 'Accept: application/grpc-web-text' -H 'X-Grpc-Web: 1' -H 'Access-Control-Allow-Credentials: true' -H 'Origin: http://ec2-52-78-24-195.ap-northeast-2.compute.amazonaws.com' -H 'Referer: http://ec2-52-78-24-195.ap-northeast-2.compute.amazonaws.com/' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: ko,en-US;q=0.9,en;q=0.8' --data-binary 'AAAAACYSJDdkODUzODk1LTMyZjYtNGE0OWEtMjNiOS1hN2NiMWU1NjVmOA==' --compressed --insecure
AAAAAEAKJDdkODUzODk1LTMyZjYtNGE0OWEtMjNiOS1hN2NiMWU1NjVmOBIYNWUzY2U5ZTJkM2FkYTQwNTZmYjI2Nzg0gAAAAB5ncnBjLXN0YXR1czowDQpncnBjLW1lc3NhZ2U6DQo=curl -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H -H -H 'DNT: 1' - 0.01s user 0.02s system 13% cpu 0.207 total

@lqez
Also as you mentioned, We introduced Route53, ACM(AWS Certificate Manager), ELB.

[Route53] - [ELB] - [EC2]

@lqez

As you informed me, I applied for the open source support program, AWS Credits for Open Source Projects for https://yorkie.dev. If we receive credit from AWS, we will be able to build Yorkie backend for small production workloads.

[LB] - [Web servers] - [Yorkie servers with ETCD] - [DB servers]

Web servers: EC2 t-small
Yorkie servers with ETCD: EC2 t-medium
DB servers: EC2 t-medium