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

Add possibility to sync container files with CDN #81

Open
tsteur opened this issue Sep 20, 2018 · 10 comments
Open

Add possibility to sync container files with CDN #81

tsteur opened this issue Sep 20, 2018 · 10 comments
Labels
Enhancement New feature or request

Comments

@tsteur
Copy link
Member

tsteur commented Sep 20, 2018

In the beginning we would probably only support one CDN, for example Amazon CloudFront. But we would make it pluggable so any adapters can be added. @mattab as this could be useful for matomo.js tracker file as well, should be maybe instead add this feature to core and tag-manager would simply use the core feature?

@tsteur tsteur added the Enhancement New feature or request label Sep 20, 2018
@mattab
Copy link
Member

mattab commented Sep 20, 2018

It would be ideal in core 👍
considering all that we have achieved in the last few years, I feel the CDN support is the last missing piece to guarantee optimal performance at all levels in matomo 🚀

@tsteur
Copy link
Member Author

tsteur commented Oct 1, 2018

I presume many/most CDNs don't need to upload a file to the CDN but they fetch it automatically. Possibly more interesting be a feature to invalidate the cache on a CDN.

@scysys
Copy link
Contributor

scysys commented Oct 2, 2018

I already using it with an CDN. On the most CDN´s it makes no sense in my opinion to upload these files. They automatically fetch it and it´s just working.

Sure, an feature to invalidate the cache would be great, but it saves just an minute to login to the CDN and invalidate the cache.

@lockland
Copy link
Contributor

I already using it with an CDN. On the most CDN´s it makes no sense in my opinion to upload these files. They automatically fetch it and it´s just working.

Sure, an feature to invalidate the cache would be great, but it saves just an minute to login to the CDN and invalidate the cache.

Hello @scysys
Do you have a tutorial to do this configuration?
What CDN are you using in your scenario?

@SARAVANA1501
Copy link

@tsteur Instead save the script in CDN, Can we store the script in database and enable the endpoint to serve the script from db?

@tsteur
Copy link
Member Author

tsteur commented Jun 11, 2020

@SARAVANA1501 it's currently not possible to store it in the DB (which would be likely bit slow)

@SARAVANA1501
Copy link

SARAVANA1501 commented Jun 11, 2020

@tsteur We are trying to host tag manager in load balancing environment, I would like to contribute to this, Would you give me the technical details for CDN sync?

@tsteur
Copy link
Member Author

tsteur commented Jun 11, 2020

If you are familiar with PHP you would want to create a plugin
and then listen to this event:

  • TagManager.containerFileChanged which has an argument $file

So you could listen to that event using a method like

syncWithCdn($pathToFile) { ... do the sync logic ... }

eg like

class CDN extends \Piwik\Plugin
{

    public function registerEvents()
    {
        return array(
            'TagManager.containerFileChanged' => array('function' => 'onStaticFileChanged', 'after' => true),
      );
    }

    public function onStaticFileChanged($file)
    {
        $s3Client = new S3Client();
        $s3Client->putObject(basename($file), file_get_contents($file));
    }
 
}

This is not tested but something like this should do

@krithikabalu
Copy link

@tsteur can you please elaborate on "it's currently not possible to store script in the DB"? If we are able to store scripts in db and serve them through endpoint, wouldn't matomo tagmanager be independently supporting multi_server_environment?

@tsteur
Copy link
Member Author

tsteur commented Jun 11, 2020

You could also store it in DB and develop your own endpoint to serve it. It just be significantly slower compared to a CDN plus it puts more load on your DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants