Using public static IP instead of localhost makes the test slow

I run Appium server and Python script at the same machine and I am using public static IP.
But it was too slow, for example, it takes 10 seconds between clicks.

After I change the IP to be 127.0.0.1, it takes 1 second between clicks.

I created this topic because I am curious about it and want to know the reason.

I used traceroute to check the speed, but it doesn’t seems like it is the bottle neck

% traceroute 127.0.0.1:
traceroute to 127.0.0.1 (127.0.0.1), 64 hops max, 52 byte packets
1 localhost (127.0.0.1) 0.334 ms 0.046 ms 0.034 ms
% traceroute MY_IP:
traceroute to MY_IP (MY_IP), 64 hops max, 52 byte packets
1 MY_IP (MY_IP) 4.529 ms 0.465 ms 0.416 ms

Machine OS:
macOS Big Sur 11.6

Appium-Python-Client version:
2.1.0

appium-doctor result:
user@AD01675489-3 ~ % appium-doctor
info AppiumDoctor Appium Doctor v.1.16.0
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor :heavy_check_mark: The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor :heavy_check_mark: Node version is 17.2.0
info AppiumDoctor :heavy_check_mark: Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor :heavy_check_mark: Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor :heavy_check_mark: DevToolsSecurity is enabled.
info AppiumDoctor :heavy_check_mark: The Authorization DB is set up properly.
info AppiumDoctor :heavy_check_mark: Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.38.0
info AppiumDoctor :heavy_check_mark: HOME is set to: /Users/user
info AppiumDoctor :heavy_check_mark: ANDROID_HOME is set to: /Users/user/Library/Android/sdk
info AppiumDoctor :heavy_check_mark: JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
info AppiumDoctor Checking adb, android, emulator
info AppiumDoctor ‘adb’ is in /Users/user/Library/Android/sdk/platform-tools/adb
info AppiumDoctor ‘android’ is in /Users/user/Library/Android/sdk/tools/android
info AppiumDoctor ‘emulator’ is in /Users/user/Library/Android/sdk/emulator/emulator
info AppiumDoctor :heavy_check_mark: adb, android, emulator exist: /Users/user/Library/Android/sdk
info AppiumDoctor :heavy_check_mark: ‘bin’ subfolder exists under ‘/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home’
info AppiumDoctor ### Diagnostic for necessary dependencies completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
info AppiumDoctor :heavy_check_mark: opencv4nodejs is installed at: /usr/local/lib. Installed version is: 5.6.0
info AppiumDoctor :heavy_check_mark: ffmpeg is installed at: /usr/local/bin/ffmpeg. ffmpeg version 4.4.1 Copyright © 2000-2021 the FFmpeg developers
info AppiumDoctor :heavy_check_mark: mjpeg-consumer is installed at: /usr/local/lib. Installed version is: 2.0.0
info AppiumDoctor :heavy_check_mark: set-simulator-location is installed
info AppiumDoctor :heavy_check_mark: idb and idb_companion are installed
info AppiumDoctor :heavy_check_mark: applesimutils is installed at: /usr/local/bin/applesimutils. Installed versions are: applesimutils 0.9.4
info AppiumDoctor :heavy_check_mark: ios-deploy is installed at: /usr/local/bin/ios-deploy. Installed version is: 1.11.4
info AppiumDoctor :heavy_check_mark: bundletool.jar is installed at: /Users/user/Library/Android/sdk/build-tools/bundletool.jar
info AppiumDoctor :heavy_check_mark: gst-launch-1.0 and gst-inspect-1.0 are installed at: /usr/local/bin/gst-launch-1.0 and /usr/local/bin/gst-inspect-1.0
info AppiumDoctor ### Diagnostic for optional dependencies completed, no fix possible. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor

I’d try to enable debug or even trace logging in urllib3 (it’s used by selenium API to perform requests to the server) and see what makes it so slow.

1 Like