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

Handling assets for scaling #116

Open
samdark opened this issue Jun 9, 2016 · 10 comments
Open

Handling assets for scaling #116

samdark opened this issue Jun 9, 2016 · 10 comments

Comments

@samdark
Copy link
Owner

samdark commented Jun 9, 2016

For https://github.com/samdark/yii2-cookbook/blob/master/book/scaling.md it's necessary to describe on how to deal with assets.

@samdark
Copy link
Owner Author

samdark commented Jun 9, 2016

@petrabarus
Copy link
Contributor

There is one more issue though. For non session-sticky load balancing, you might fail finding an asset.

Let's say 1st request hit server A, the asset will be generated in the local storage inside server A. And then when the 2nd request sent to get the asset but hit server B which hasn't generated the asset, it will return 404.

My suggestion are

  1. Use shared storage or NFS to store the storage.
  2. Compile the assets using yii asset in build process and store it in centralized storage like AWS S3.
  3. Or create new assset manager class that can check cache or centralized storage and then generate the asset on the fly if not exists.

@petrabarus
Copy link
Contributor

Or you can just configure the load balancer to use session-sticky.

@samdark
Copy link
Owner Author

samdark commented Jun 9, 2016

Good suggestions. Do you have time to include these into the article?

petrabarus added a commit to petrabarus/yii2-cookbook that referenced this issue Jun 9, 2016
@petrabarus
Copy link
Contributor

Working on it. Now that there is a topic about scaling. I think I haven't found any topic about continuous integration. Might be useful.

@samdark
Copy link
Owner Author

samdark commented Jun 9, 2016

Absolutely. Would be great if you'll share your experience.

samdark pushed a commit that referenced this issue Jun 10, 2016
* [WIP] Asset managements in scaled environment #116

* Update scaling.md

* Update scaling.md

* Update scaling.md

* Update scaling.md
@chizuoka
Copy link

i run an api for user creation so avatars and user photos are created in production so shared storage, google cloud storage is necessary. May i know how it can be configured so all the servers have a central storage on google cloud storage.

@gusev-genotek
Copy link

gusev-genotek commented Jul 25, 2017

Second @chizuoka request. I am using google app engine flex custom environment, everything works great, the last issue is sharing user generated content (such as, for example, avatars) via a single google cloud storage across horizontally scaled VM's with stateless Yii2 application. Any pointers would be appreciated so that I could develop it myself.

@razvanphp
Copy link

If we could have a pluggable storage AssetManager class, for example with creocoder/yii2-flysystem, then all our problems would be solved.

@samdark
Copy link
Owner Author

samdark commented Apr 12, 2019

That's something for Yii 3.0.

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

No branches or pull requests

5 participants