Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDNSource: Use a more compact, sharded index retrieving for the pod versions #541

Merged
merged 2 commits into from Jun 12, 2019

Conversation

igor-makarov
Copy link
Contributor

@igor-makarov igor-makarov commented May 21, 2019

So this is the new iteration of CDNSource. It no longer relies on per-pod index.txt files, but similar to RubyGems, utilizes concentrated version index files.

The per-shard files are named all_pods_versions_9_a_4.txt and are assumed to be located in the root of the repo. The content of each file is of the following format:

PodName/1.0.3/1.1/1.1.1/1.1.2/1.1.3/1.1.4

This change reduces the amount of deployment work down to 2 minutes on Netlify and there are as many files as there are shards (4,096).

I've also added to CDNSource the capability to follow redirects.

I've updated the tests and I believe new tests aren't necessary at this moment.

Netlify deployment has been completed and is possible and running.

@igor-makarov igor-makarov changed the title Use a more compact, one-file index for all the pods Use a more compact, one-file index for all the pods - Netlify deployment is possible! May 22, 2019
@igor-makarov igor-makarov marked this pull request as ready for review May 22, 2019 08:04
@igor-makarov igor-makarov reopened this May 22, 2019
@igor-makarov igor-makarov changed the title Use a more compact, one-file index for all the pods - Netlify deployment is possible! CDNSource: Use a more compact, one-file index for all the pods - Netlify deployment is possible! May 22, 2019
@igor-makarov
Copy link
Contributor Author

I've been talking to Netlify about an open source license and they seem to be okay with hosting the CocoaPods spec repo cache.

This is their open source program page.

Additionally, proxying Netlify through jsDelivr would work as well. I've talked to them as well and they handle all the specifics correctly.

@@ -0,0 +1,2 @@
BeaconKit/1.0.0/1.0.1/1.0.2/1.0.3/1.0.4/1.0.5
SDWebImage/2.4/2.5/2.6/2.7/2.7.4/3.0/3.1/4.0.0/4.0.0-beta/4.0.0-beta2
Copy link
Member

Choose a reason for hiding this comment

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

I like this version better than the previous draft since its a bit more compact 👍

Copy link
Member

Choose a reason for hiding this comment

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

can Pods have '/' in their name? I'm not 100% if they can, but we might have to think about escaping things here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I managed to find, there are no pods with slashes. While theoretically possible, it's pretty hard to create a file with a slash in the name.

I don't know if pod linting checks for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I think Pod/Name is reserved for subspecs.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that sounds right

@igor-makarov
Copy link
Contributor Author

@amorde Keep in mind that while being more compact and performant (entire zip is only 750KB), using it will generate more CDN traffic, as each podspec publish will cause the entire index to get dirty.

@amorde
Copy link
Member

amorde commented May 29, 2019

Yup was actually referring to this PR when it was a draft and had the compact index but the versions all on separate lines. Good point though on the traffic. Maybe there's a middle ground in which we separate this into smaller chunks, but not as many chunks as before.

What if we did something similar to the spec repo sharing, and had an index per starting character (ex. a-pods.txt, b-pods.txt, 1-pods.txt)?

@igor-makarov
Copy link
Contributor Author

Considering the random-like nature of the shard hash function, and the fact that most projects have multiple pods, I don't think sharding the compact index would help much. Unless you shard it all the way, but that might cause problems when building on Netlify.

Ultimately, this index will be downloaded only when creating and updating a repo. Additionally, jsDelivr said they don't have a problem being the CDN in front of Netlify.

@igor-makarov
Copy link
Contributor Author

Alright! I've tested deploying full sharded indexes on Netlify and it works okay. Turns out they don't have a problem with ~4k files, only ~700k files. 🙃
This new version has a text file for each shard, named like all_pods_versions_9_a_4.txt where the suffix is the shard path. Each file is around 1KB, and while my total (for a project with 30 pods) was 300KB - these aren't expected to churn as much!

@igor-makarov igor-makarov changed the title CDNSource: Use a more compact, one-file index for all the pods - Netlify deployment is possible! CDNSource: Use a more compact, sharded index for the pods' versions Jun 10, 2019
@igor-makarov
Copy link
Contributor Author

Now that Netlify deployment is up, this can be merged safely.

@igor-makarov igor-makarov changed the title CDNSource: Use a more compact, sharded index for the pods' versions CDNSource: Use a more compact, sharded index retrieving for the pod versions Jun 10, 2019
@igor-makarov
Copy link
Contributor Author

I've updated the original PR comment to reflect the code that's being PR'd.

@dnkoutso dnkoutso added this to the 1.8 milestone Jun 11, 2019
@amorde amorde merged commit 0e8a708 into CocoaPods:master Jun 12, 2019
@igor-makarov
Copy link
Contributor Author

Awesome! 💪

@igor-makarov igor-makarov deleted the cdn-repo-huge-index branch June 13, 2019 05:29
@dnkoutso
Copy link
Contributor

dnkoutso commented Jun 13, 2019

Cherry-picked to 1-7-stable here.

@dnkoutso dnkoutso modified the milestones: 1.8, 1.7 Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants