目的
- 未公開記事の発掘
- ニッチな話題だった
2015年からGCSにMaven Centralのコピーを公開するようになったそうです。知らなかった。
どれくらい違いが出るのか検証してみる。
検証
対象のホストは以下。
- Maven Central(repo.apache.maven.org)
- Maven Central の公式ホスト
- GCS-Asia(maven-central-asia.storage-download.googleapis.com)
- GCS の Asia 地域向けホスト
- GCS-EU(maven-central-eu.storage-download.googleapis.com)
- GCS の EU 地域向けホスト
- GCS-US(maven-central.storage-download.googleapis.com)
- GCS の US 地域向けホスト
計測は curl
で行う。それぞれのホストに対して5回。
$ for m in repo.apache.maven.org maven-central-asia.storage-download.googleapis.com maven-central-eu.storage-download.googleapis.com maven-central.storage-download.googleapis.com; do for i in {0..5}; do curl -s -k -w "${m},${i},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}\n" -o /dev/null https://${m}/maven2/org/springframework/spring-core/5.3.8/spring-core-5.3.8.jar; done done repo.apache.maven.org,0,0.037991,0.163917,0.422735,0.422971,0.000000,0.546282,0.546399 repo.apache.maven.org,1,0.004278,0.121880,0.364024,0.364144,0.000000,0.481385,0.481420 repo.apache.maven.org,2,0.001639,0.119328,0.361785,0.361857,0.000000,0.486429,0.486477 repo.apache.maven.org,3,0.002099,0.124872,0.380066,0.380149,0.000000,0.507271,0.507390 repo.apache.maven.org,4,0.001770,0.125946,0.380944,0.381223,0.000000,0.506575,0.506630 repo.apache.maven.org,5,0.001851,0.124397,0.376576,0.376872,0.000000,0.502826,0.502898 maven-central-asia.storage-download.googleapis.com,0,0.001884,0.009613,0.055196,0.055288,0.000000,0.068453,0.224391 maven-central-asia.storage-download.googleapis.com,1,0.002481,0.013766,0.068994,0.069050,0.000000,0.088661,0.270275 maven-central-asia.storage-download.googleapis.com,2,0.003084,0.012668,0.063887,0.064081,0.000000,0.072885,0.235593 maven-central-asia.storage-download.googleapis.com,3,0.001820,0.009232,0.054758,0.054809,0.000000,0.062724,0.227797 maven-central-asia.storage-download.googleapis.com,4,0.004236,0.021772,0.079667,0.079779,0.000000,0.092243,0.263077 maven-central-asia.storage-download.googleapis.com,5,0.002611,0.044696,0.101837,0.101898,0.000000,0.118384,0.305925 maven-central-eu.storage-download.googleapis.com,0,0.001900,0.011311,0.066934,0.067014,0.000000,0.082776,0.257083 maven-central-eu.storage-download.googleapis.com,1,0.001837,0.023069,0.078694,0.078742,0.000000,0.096553,0.287659 maven-central-eu.storage-download.googleapis.com,2,0.002092,0.018734,0.327978,0.328036,0.000000,0.345902,0.521407 maven-central-eu.storage-download.googleapis.com,3,0.002118,0.019215,0.070883,0.071256,0.000000,0.083224,0.271967 maven-central-eu.storage-download.googleapis.com,4,0.004461,0.018585,0.074322,0.074431,0.000000,0.088315,0.252058 maven-central-eu.storage-download.googleapis.com,5,0.001913,0.015818,0.065436,0.065493,0.000000,0.076168,0.245924 maven-central.storage-download.googleapis.com,0,0.002025,0.016342,0.068950,0.069062,0.000000,0.082023,0.293154 maven-central.storage-download.googleapis.com,1,0.001882,0.017747,0.074114,0.074177,0.000000,0.085885,0.264096 maven-central.storage-download.googleapis.com,2,0.002242,0.016268,0.071127,0.071346,0.000000,0.086131,0.259000 maven-central.storage-download.googleapis.com,3,0.002341,0.016438,0.069612,0.069663,0.000000,0.085434,0.279309 maven-central.storage-download.googleapis.com,4,0.014452,0.028634,0.077995,0.078046,0.000000,0.088248,0.257237 maven-central.storage-download.googleapis.com,5,0.002168,0.016135,0.066451,0.066529,0.000000,0.077767,0.278174
集計結果。値の単位は秒で、5回の単純平均。最小値に(*)
を付けてみた。
Maven Central は fastly を使ってても速さが出てないようだ。キャッシュが効いてるのかどうかはわからない。 合計時間のオーダーはあまり変わらない(250msと500ms)から、データ転送は速そう。
ホスト | GCS-US | GCS-Asia | GCS-EU | Maven Central |
---|---|---|---|---|
time_namelookup | 0.004185 | 0.002686(*) | 0.002386 | 0.008271 |
time_connect | 0.018594 | 0.018624 | 0.017788(*) | 0.130056 |
time_appconnect | 0.071374 | 0.070723(*) | 0.114041 | 0.381021 |
time_pretransfer | 0.071470 | 0.070817(*) | 0.114162 | 0.381202 |
time_starttransfer | 0.084248 | 0.083891(*) | 0.128823 | 0.505128 |
time_redirect | 0 | 0 | 0 | 0 |
time_total | 0.271828 | 0.254509(*) | 0.306016 | 0.505202 |
設定の仕方
Maven
${HOME}/.m2/settings.xml
あるいは%USERPROFILE%\.m2\settings.xml
へ次のように記述する。
つまり、 settings
要素の子要素を追加すればよい。
<settings> <!-- 何かしらの設定 --> <mirrors> <mirror> <id>google-maven-central</id> <name>GCS Maven Central mirror Asia Pacific</name> <url>https://maven-central-asia.storage-download.googleapis.com/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <!-- 何かしらの設定 --> </settings>
Gradle
${HOME}/.gradle/init.gradle
あるいは%USERPROFILE%\.gradle\init.gradle
を作成して次のように記述する。
allprojects { buildscript { repositories { mavenLocal() maven { url "https://maven-central-asia.storage-download.googleapis.com/maven2/" } } } repositories { mavenLocal() maven { url "https://maven-central-asia.storage-download.googleapis.com/maven2/" } } }