Sitespeed.io: Using Sitespeed in Kubernetes

Created on 23 Nov 2017  路  19Comments  路  Source: sitespeedio/sitespeed.io

Hi there,

we are currently setting up sitespeed.io Tests in our Kubernetes Cluster. So far it worked pretty straight forward, but now we hit kind of a deal-breaking problem:
Kubernetes does not support throttling network connections, so we can only run our tests without any throttling. This makes them pretty inconsistent and not reliable.

We cannot use tc in Kubernets to set up throttled Networks. Do you know of any alternative? Maybe a Docker Container that throttles another Container?
We are thankful for any help because we would really like to use this tool.

Thanks!

Most helpful comment

@Sly777 You basically need to use a Kubernetes CronJob that creates a normal Job every N minutes. I will soon write a blog post about this on https://blog.rphl.io/ if you are interested. You can also contact me via E-Mail ([email protected])

All 19 comments

Hey @Algram I've heard other people that had problem with throttling So if I understand correctly you cannot use tc inside the container or setting up Docker networks?

You could try https://github.com/WPO-Foundation/tsproxy - we had it in Browsertime but removing to 2.0 now, since for us it didn't work out so good (it became really slow) but maybe the problem is how we do it (start it in NodeJS etc) because the Chrome team uses in internally and it "should" work. What happend for us was that a page could take minutes to load even though the it should take seconds. But you can easily test that I think. Please le us know if you need more help and how it worked out.

Best
Peter

Yeah, that is exactly the problem.

Okay tsproxy looks a little bit more promising. If I understand correctly we would have to create a proxy for every network speed we have, correct? How would we pass the proxy through to chrome in the docker container? Is there a command line argument for that?

yep or start/stop/change it between runs, it depends on your setup. This is how we used to run it with Chrome and Firefox.

Okay in the code you linked browsertime is setting "localhost" fro the name of the tsproxy. In our case tsproxy is not on localhost though but has a separate hostname. Is there any way in the current implementation to also set that?

That was meant as an examp枚e, you shouldn't use the built in TSProxy as it doesn't work but you should try to run it standalone outside of Browsertime and see if it is ok and then you pass on the cli params to Chrome. That's the best way I think.

Yeah exactly so my question was how do I pass cli params to chrome with the sitespeed runner?

Ah sorry. Every cli parameter you pass on with --browsertime.X will be passed to browsertime, so you can configure the exact same thing using sitespeed.io

In browsertime you pass ----chrome.args and if you want to do that from sitespeed you just --browsertime.chrome.args to set chrome command line arguments.

Okay thanks a lot! I will try and set that up and inform you if it works or not.

So I am passing the proxy option lik that, but it does not seem to work. Any suggestions? --browsertime.chrome.args='--proxy-server=socks5://123.456.789.1:1080'

hmm, we miss that in the docs, you should leave out -- in the args to Chrome. --browsertime.chrome.args='proxy-server=socks5://123.456.789.1:1080' - I tried on my local machine and it worked.

We finally got the proxy working in our cluster now! One of the pitfalls was that we needed to specify the cli parameter without the '. Otherwise the cli parameter won't be interpreted by kubernetes.
If you have any further questions, feel free to ask :)

Aha thanks. Looking forward to your blog post @Algram ;)

One question: do the timings from the proxy looks ok? I remember when I was trying out https://en.wikipedia.org/wiki/Barack_Obama on cable or was it 3g the total load time was over a minute (but should be seconds).

Well it heavily depends on the speeds configured in tspoxy I guess, but the values we get seem to be reasonable for the speeds we set.

INFO: 85 requests, 1205.25 kb, backEndTime: 6.28s, firstPaint: 12.82s, firstVisualChange: 13.97s, DOMContentLoaded: 13.80s, Load: 43.96s, speedIndex: 20253, visualComplete85: 19.93s, lastVisualChange: 39.97s, rumSpeedIndex: 19712

These are the load times that we get with the following configuration for the Proxy:
CMD [ "python", "tsproxy.py", "--rtt=1000", "--inkbps=768", "--outkbps=768" ]

I will monitor that over a longer time frame with different speeds though and see if it matches.

Thanks again for sharing @Algram !

@Algram I close this now. Thanks for sharing and what about writing a blog post of how you do it for the Performance Calendar - http://www.phpied.com/performance-calendar-17-call-to-all/ ?

Hey @Algram how do you run sitespeed command on kubernetes? I prepared everything except sitespeed run :D Normally I was using the command below on docker compose.

docker-compose run --rm sitespeed.io https://testwebsite.com/ --config /config/sitespeed-config.json

I don't know how to convert to kubernetes

@Sly777 You basically need to use a Kubernetes CronJob that creates a normal Job every N minutes. I will soon write a blog post about this on https://blog.rphl.io/ if you are interested. You can also contact me via E-Mail ([email protected])

@Algram let us know when you publish it so we can link to it from the docs :)

@Algram Hi, are you still running this kind of setup with tsproxy? I have tried to set this up with cronjobs but after a few runs the proxy gets really slow and still I am running it on preemtibles that "restarts" the machine after ~24h. Would be really interesting to know how you manage to do this.

Was this page helpful?
0 / 5 - 0 ratings