Jump to content

[WEB] KSP Ribbon Generator [v2.0, Dec 22, 2014] Over 7 Million Served!


Recommended Posts

Creating static images from the generation code is a snap, so I suspect that if/when I do start to have issues, it will be with bandwidth rather than CPU.

Rad. I'll keep an eye out for bandwidth saving techniques instead of CPU saving.

Thanks again for rescuing this project! It's important to me and you're doing a great job of it. Looking out at the number of broken images in people's signatures I can tell that you're making a huge impact!

Link to comment
Share on other sites

I did a little research today on CDNs and found two promising options that you could consider. Since this is what caused the original system to shut down, it seems like a good thing to figure out now.

The two options I found were CoralCDN and CloudFlare's free service.

CloudFlare - https://www.cloudflare.com/plans

Professional CDN which offers upgrades. The next plan is only $20/month which we could probably figure out together if we needed. Takes some configuration but it seems like a pretty good option.

CoralCDN - http://wiki.coralcdn.org/clients.html

Peer-to-peer CDN that's been up for a decade or so. When I tried it out the DNS connection was sluggish, so this may be a bad option. On the other hand, it requires almost no changes at all; all you have to do is add nyud.net to your image links and you'll only get caching immediately. My guess is you'd reduce bandwidth by about 80-90%. The question in my mind is the slow DNS resolution that I experienced tonight. (Could just be my router though!)

If you want to try it, here's the image from your signature: http://www.kerbaltekaerospace.com.nyud.net/users/ezriilc/Ezriilc_KSP-Ribbons.png

Link to comment
Share on other sites

I Was already using cloudflares on the old website and it was causing alot of problems with certain users.. But it was saving about half the bandwith. But bandwith was not my problem, My script was not super efficient and the server ressources werre very limited

Link to comment
Share on other sites

I did a little research today on CDNs and found ...
That link to nyud.net for my siggy pic is failing with "server not found".

However this is some great information, and I think we will likely use something like these in the near future. I really appreciate your offer to help!

I Was already using cloudflares on the old website and it was causing alot of problems with certain users.. But it was saving about half the bandwith. But bandwith was not my problem, My script was not super efficient and the server ressources werre very limited
Hey there, Moustachauve! I thought you had disappeared - glad to see you around. :)

I have no idea how efficient my code is, and I'd really love to have your opinion. Could you take a look at it and give me a critique? :blush:

To all: Here's my plan. I'm going start generating static images for Kerbaltek members that are logged in. Once I get that in place, I can then log and track the requests to them, to see where any problems may lie - if any. For all I know, this may turn out to be a non-issue. I've just been very cautious up to this point.

Edited by Ezriilc
Link to comment
Share on other sites

So, does anyone have any advice/ideas about site structure for static images? Should we have...?

  1. a sub-domain (e.g.: ribbons.kerbaltek.com/{username}.png) - does this have advantages later with a CDN or whatever?
  2. a directory for ribbon images (e.g.: kerbaltek.com/ribbons/{username}.png)
  3. a directory for each user (e.g.: kerbaltek.com/users/{username}/ribbons.png)

I want to do this carefully, so it doesn't need to be changed, like... ever again.

Link to comment
Share on other sites

So, does anyone have any advice/ideas about site structure for static images? Should we have...?

  1. a sub-domain (e.g.: ribbons.kerbaltek.com/{username}.png) - does this have advantages later with a CDN or whatever?
  2. a directory for ribbon images (e.g.: kerbaltek.com/ribbons/{username}.png)
  3. a directory for each user (e.g.: kerbaltek.com/users/{username}/ribbons.png)

I want to do this carefully, so it doesn't need to be changed, like... ever again.

For now, I'm hosting static images for each registered member, at their own address. Just login and generate your ribbons, to create and save your image. Then you can link directly to it.

http://kerbaltek.com/users/{username}/ribbons.png

WARNING: THIS MAY CHANGE AT ANY TIME - if it becomes a problem, or I think of a better way.

Link to comment
Share on other sites

So, when is this going to be updated with 0.90 compatibility? :wink:
Done! I just re-wrote all my code again today! :wink:
I'm thinking about making rank insignias and ribbons for Kerbals of various specialties, though that might be better suited to Final Frontier or a thread of its own.
Interesting. I have plans to build an in-game plugin that would automatically generate a ribbon set for each Kerbal. Your rank insignias might go nicely in that, and could even be added to this generator. Perhaps we should team-up?
Link to comment
Share on other sites

I tried to register for Kerbaltek but it gave me a db error last night. Now when I request a new token it doesn't ever send an email to me. :/

To the question of how to do icon urls:

The one thing you have to do is to version the ribbon in addition to the user-id. Otherwise when people make changes they won't see them if you do decide to do a cdn. Unfortunately, you can't use ?v=1234 because cdn's often won't cache anything with a query string. So it really needs to be something like `/<userid>/ribbon-<version>.png`

But I would still recommend that individual ribbons combinations have urls instead of users. But I don't know if BBCode would support that. There are many variations, but as an example, many people who visit the sun only rocket into it and call it a day. That's the extent of their sun experience, so if there was `/sun/crashed.png`, most people would end up hitting the same cache.

Even better, you could use the bitmask strategy and say something like, crashed = 1, visit = 2, orbit = 4, returned = 8, pod = 16 which would allow something like `/sun/10011.png` which would mean: crashed, visited, in a pod. Anyone that did something similar would get the same ribbon. There would be a lot of misses, but the expiration is infinite and no matter how people changed their ribbons the cache entry would still be fine. There would also be almost zero cpu load because each ribbon combo would need to be built and stored on the filesystem once. The only thing that would change would be the html to display the ribbon in the signature.

What do you think?

Link to comment
Share on other sites

I tried to register for Kerbaltek but it gave me a db error last night. Now when I request a new token it doesn't ever send an email to me. :/
OOPS! I found and fixed a problem with a recent update to the DB code - sorry about that. :blush:

Emails seem to be going out properly, so please give it another try. Thanks for the report!

The one thing you have to do is to version the ribbon in addition to the user-id. Otherwise when people make changes they won't see them if you do decide to do a cdn. Unfortunately, you can't use ?v=1234 because cdn's often won't cache anything with a query string. So it really needs to be something like `/<userid>/ribbon-<version>.png`

But I would still recommend that individual ribbons combinations have urls instead of users. But I don't know if BBCode would support that. There are many variations, but as an example, many people who visit the sun only rocket into it and call it a day. That's the extent of their sun experience, so if there was `/sun/crashed.png`, most people would end up hitting the same cache.

Even better, you could use the bitmask strategy and say something like, crashed = 1, visit = 2, orbit = 4, returned = 8, pod = 16 which would allow something like `/sun/10011.png` which would mean: crashed, visited, in a pod. Anyone that did something similar would get the same ribbon. There would be a lot of misses, but the expiration is infinite and no matter how people changed their ribbons the cache entry would still be fine. There would also be almost zero cpu load because each ribbon combo would need to be built and stored on the filesystem once. The only thing that would change would be the html to display the ribbon in the signature.

What do you think?

I think you are a valuable asset on this subject and I plan to keep you handy, but I'm not going to worry about this too much, until I have an issue to address. Now that I've started the test, I can collect some data and see where the numbers lead us.

I kinda like the idea of giving users their own folders where their ribbons go, and maybe other stuff in future.

The bitmask idea is a good one that I've considered - if just briefly.

Thanks for all your input, vosechu! It really is helping me to get a better handle on where I stand with this.

Link to comment
Share on other sites

Absolutely :)

It feels great to be appreciated. Thank /you/!

Keeping them in folders is probably fine. You won't see as much gain from a cdn, but that's okay. And it's okay if you don't change the name of the actual file either, usually http does okay at this. I think part of my suggestion was that we were doing some cache-busting today at work. Cursed JS cache busting breaking our production deploys... :)

Anyways, I'm glad you're doing this. It's really awesome. When I get logged in I'm totally going to build my ribbon thingy :P

Edited by vosechu
Link to comment
Share on other sites

Btw, now that I see the testing stats on login I'm seeing that caching by ribbon would indeed be quite difficult.

https://www.evernote.com/shard/s49/sh/36cc8d05-353d-4984-a074-f636a499dd57/9c76966557bf98923d1887a5dc86bf14

This sun is a great example. Our visits were so similar, yet even though we did basically the same things, we represented it differently. So even the sun, my prime example of winning through caching, doesn't really work. :)

Link to comment
Share on other sites

Between December 10th, and December 12th (when I updated the site), the number of daily hits has tripled, but the bandwidth dropped 50%! Hopefully, this means we're in good shape.

Edited by Ezriilc
Link to comment
Share on other sites

Awesome! Btw, the BBCode generated has EZriilc hard-coded into it. Which looks much more impressive in my signature, but I thought I'd mention it :P

Are you freakin' serious?! I must have looked at that a thousand times and missed it. Long night...

FIXED!

Link to comment
Share on other sites

Last question for the day, do we need to hit generate when we make changes? I only ask because it downloads the ribbon for me which makes me think that it's disconnected from saving.

If the hotlinking is working, maybe that button could change to Save and it could not auto-download the image?

Link to comment
Share on other sites

Worked for you :P
[facepalm] I need more testers! [shakes fist at sky]
Last question for the day, do we need to hit generate when we make changes? I only ask because it downloads the ribbon for me which makes me think that it's disconnected from saving.

If the hotlinking is working, maybe that button could change to Save and it could not auto-download the image?

EDIT: Answer: Yes. Clicking Generate saves to the DB, but doesn't reload the page.

mmm... good point. I hemmed and hawed about how to make that intuitive and simple. I'm thinking I might go back to separate Save and Generate buttons.

Link to comment
Share on other sites

Sounds good!

Also, I'd be happy to be your tester if you're being serious. You could text or email whenever it's late and you need a second pair of eyes. Or it you want someone to look at code; I've not done php in about three years but it's not hard to read. As you know, I am a dev in my day job.

Link to comment
Share on other sites

Sounds good!

Also, I'd be happy to be your tester if you're being serious. You could text or email whenever it's late and you need a second pair of eyes. Or it you want someone to look at code; I've not done php in about three years but it's not hard to read. As you know, I am a dev in my day job.

I formally accept your help. I keep a GitHub repo here: https://github.com/Ezriilc/KSP-Ribbon-Generator

But the code there is a bit out of date. I will push an update to that repo soon.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...