Skip to content

🔍To choose the best CloudFront IPs for achieving fast and low-latency connections

License

Notifications You must be signed in to change notification settings

BruceWind/CloudFrontIPSelector

Repository files navigation

CloudFrontIPSelector

中文English

This project helps choose the best CloudFront IPs for achieving fast and low-latency connections.

Background

Because AWS's DNS function is so good, users of AWS CloudFront typically report having an extremely steady experience.

On the other hand, those living in China use it often get timeout, shipments lost and high latency. As a result, some people prefer to bind to CloudFront's domain using low-latency IP addresses. I created this script to choose IPs with the lowest latency in these situations.

How to use?

  1. set up node environment

In case people who havn't set up node. I highly recommand nvm or nvm-windows to set up.

  1. connect to a stable network environment

Please note that when the WIFI connection is unstable, it may result in a longer latency between your computer and router. This can have a negative impact on the scan process and may affect the accuracy of the results.

It is recommended to connect an ethernet wire and your computer, otherwise you must make sure your WIFI connection is stable. Without a stable connection, this script may can not obtain any IPs that latency below threshold. A tips to know if your WIFI connection is stable is to ping your gateway IP(e.g. 192.168.0.1 or 192.168.50.1 which depends your local-IP, whose last number changed to 1). Or move your laptop close to your router.

  1. run this JS file.
npm install
node ./  
# or you would like find IPs with nation short name like SG, you can run "node ./ SG"
  1. wait

wait minites to get result.txt which contain best IPs will be saved in this folder.

In addition

a. I limited latency of selected IPs must below 80, if you want to change it, you can modify this variable THREASHOLD in index.js.

b. Have you tried Gcore-CDN? I have written another IP-selector for Gcore: https://github.com/BruceWind/GcoreCDNIPSelector, you can try it.

c. Why don't I test the up/down speed in code? I've tested it by another method and found that all IPs of Cloudfront have very high speed. As a result, there is no evidence to suggest that different IPs have different speeds. In other words, I believe that you just need to make sure the CDN IP that you connect has low-latency.

Thanks

sapics/ip-location-db provides geoip databse.