Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[website] Redirect Chinese visitors to Apache Chinese CDN provider PART 1 #18431

Merged
merged 2 commits into from
May 30, 2020

Conversation

ys2843
Copy link
Contributor

@ys2843 ys2843 commented May 28, 2020

Description

This PR is the part1 of #18422 .To fix slow site speed in China and improve overall loading speed. It adds server side logic to redirect Chinese visitors to Chinese CDN based on Geo IP. This is the most accurate and fastest way to filter visitors.

There are 2 checks to each incoming HTTP requests.

  1. Check user Geoip country code, whether it equals to CN
  2. Check host name in URL to ensure redirect only happens when user initially attempts to access the website. Avoid any loops and subsequent redirect.

If all conditions match, redirect user to Chinese CDN with same URI. For example, redirect from https://mxnet.apache.org/features to https://mxnet.cdn.apache.org/features

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:

Changes

  • Add logic to redirect Chinese visitors to Apache's Chinese CDN provider

Comments

  • Preview: http://ec2-34-219-134-42.us-west-2.compute.amazonaws.com
  • Please note: Geo_ip is set up on this preview server. If you visit http://ec2-34-219-134-42.us-west-2.compute.amazonaws.com/testgeoip.php, you should see your ip and geolocation data.
    Following settings are used to stimulate the process:
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteCond %{HTTP_HOST} ec2-34-219-134-42.us-west-2.compute.amazonaws.com
RewriteRule ^(.*) https://mxnet.cdn.apache.org%{REQUEST_URI} [R,L]
  • Tested by several users in China, redirect works properly and there is a boost of loading speed

@mxnet-bot
Copy link

Hey @ys2843 , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [windows-gpu, sanity, windows-cpu, unix-gpu, unix-cpu, clang, centos-gpu, miscellaneous, website, edge, centos-cpu]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@ys2843 ys2843 changed the title [website] Redirect Chinese visitors to Apache Chinese CDN provider [website] Redirect Chinese visitors to Apache Chinese CDN provider PART 1 May 28, 2020
@ys2843
Copy link
Contributor Author

ys2843 commented May 28, 2020

@mxnet-label-bot update [website, pr-awaiting-merge]

@lanking520 lanking520 added pr-awaiting-review PR is waiting for code review Website labels May 28, 2020
@marcoabreu
Copy link
Contributor

@mxnet-bot run ci [miscellaneous, unix-cpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [miscellaneous, unix-cpu]

Copy link
Contributor

@aaronmarkham aaronmarkham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Anecdotally, the cdn is faster for me and I'm in California. Maybe we should just use the CDN for all traffic? We heard from another community member in Australia that the site is slow there too... wdyt?

@ys2843
Copy link
Contributor Author

ys2843 commented May 29, 2020

This is great. Anecdotally, the cdn is faster for me and I'm in California. Maybe we should just use the CDN for all traffic? We heard from another community member in Australia that the site is slow there too... wdyt?

Yeah, I will reach out to Apache to get more info about this, whether it is allowed to redirect more/all users to this CDN, or if they can point official website ip to it. But I guess it will take some time to address this issue, while this is a Chinese CDN provider that might be out of Apache's control.

@marcoabreu
Copy link
Contributor

marcoabreu commented May 29, 2020

Just checked with a tool and the results are as follows:

Original website: https://www.dotcom-tools.com/website-speed-test.aspx#2D4761ACDB144D809F0E16105FC25827
CDN website: https://www.dotcom-tools.com/website-speed-test.aspx#D08B03A9E383480C926C9946A86F6956

Generally, the original website is more consistent. The CDN has higher loading time on first as well as second visit.

Of course this would need more thorough inspection, but from the first look it seems like we should only use the CDN when there'a a specific issue we identified.

Before taking such drastic steps I'd appreciate some A/B testing or further inspection before simply moving all users to a different host. Apache servers are in our control but others might not.

@marcoabreu
Copy link
Contributor

@ys2843 please make sure to discuss topics (like generally considering a move to a CDN) on dev@ before reaching out to Apache Infra.

@ys2843
Copy link
Contributor Author

ys2843 commented May 29, 2020

Just checked with a tool and the results are as follows:

Original website: https://www.dotcom-tools.com/website-speed-test.aspx#2D4761ACDB144D809F0E16105FC25827
CDN website: https://www.dotcom-tools.com/website-speed-test.aspx#D08B03A9E383480C926C9946A86F6956

Generally, the original website is more consistent. The CDN has higher loading time on first as well as second visit.

Of course this would need more thorough inspection, but from the first look it seems like we should only use the CDN when there'a a specific issue we identified.

Before taking such drastic steps I'd appreciate some A/B testing or further inspection before simply moving all users to a different host. Apache servers are in our control but others might not.

Agreed,

@ys2843 please make sure to discuss topics (like generally considering a move to a CDN) on dev@ before reaching out to Apache Infra.

Yes, sure. This should be further discussed within the team before moving on. Currently fixing the website in China is what this project primarily aims.

@ys2843 ys2843 force-pushed the fix-slow-site-speed-part1 branch from 52b5b73 to 8d0c3be Compare May 30, 2020 05:43
@lanking520 lanking520 added pr-awaiting-merge Review and CI is complete. Ready to Merge and removed pr-awaiting-review PR is waiting for code review labels May 30, 2020
@sandeep-krishnamurthy sandeep-krishnamurthy merged commit 53a92f9 into apache:master May 30, 2020
@ys2843 ys2843 deleted the fix-slow-site-speed-part1 branch May 30, 2020 22:54
yijunc pushed a commit to yijunc/incubator-mxnet that referenced this pull request Jun 9, 2020
…RT 1 (apache#18431)

* website - redirect Chinese visitors to Apache Chinese CDN provider

* switch to mod_geoip for most accurate redirecting

Co-authored-by: Yang Shi <[email protected]>
AntiZpvoh pushed a commit to AntiZpvoh/incubator-mxnet that referenced this pull request Jul 6, 2020
…RT 1 (apache#18431)

* website - redirect Chinese visitors to Apache Chinese CDN provider

* switch to mod_geoip for most accurate redirecting

Co-authored-by: Yang Shi <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-merge Review and CI is complete. Ready to Merge Website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants