Automated Squid Caching Brainstorm Session

Discussion in 'Tomato Firmware' started by WRD - EasyTomato, Jul 18, 2012.

  1. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    Hey guys,

    I've got a feasibility question about Squid caching on an RT-N16. Hopefully someone out there has got some smart ideas...

    We're working on a Tomato version called EasyTomato (the post about it is here for some background). We are interested in getting a squid caching server working on a usb stick (one of those tiny leave-in sticks like this). As EasyTomato is going to end up in a lot of low bandwidth locations, it would be hugely helpful when you have 20 kids looking at the same online teaching resources over a satellite connection.

    Here's the catch... We want to enable/disable this all through a single toggle button in the settings page of EasyTomato. The users aren't going to install anything or set it up. Just slap a flashdrive in (and leave it in) and hit the on button.

    Think it can be done? Lets hear some smart ideas! (We don't need specific scripts or anything in this post, just a discussion of general feasibility)

  2. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    Ok, let me try to jumpstart this conversation a little...

    So we have MIPS linux running on our router. Shouldn't we be able to have it format and partition a flash drive, then download optware and squid, install it, and run it? That sounds pretty elegant to me. The end user wouldn't have to do a thing other than put in flash drive and hit go. Since EasyTomtao is already going to be doing some nice JS graphing it's easy for us give a nice overview of how much of an effect squid is having.

  3. maurer

    maurer Network Guru Member

  4. lancethepants

    lancethepants Network Guru Member

    I think that should be doable.

    The rundown as I see it, maybe skipped something.

    1.Format the device with an optware partition and swap maybe, and take note of the volume name for the optware partition.
    2. Write the fstab file to nvram as described in this link
    or put it in a startup script, using the Volume name created when previously formatted.
    3. Store the optware installation script somewhere compiled into the firmware or scripted, and run to install it.
    4. Run the command to install squid.
    5. Create the config file, possibly copy it from a place where it has been compiled into the firmware.
    6. Enable or disable squid in the tomato startup sequence with your button toggle, possibly an nvram value.

    Probably preaching to the choir, but I think very doable.
  5. koitsu

    koitsu Network Guru Member

    Your biggest problem is going to be memory, or lack thereof. Caching proxies only perform decently when given decent amounts of memory; less RAM = more disk I/O. Disk I/O in this case means asynchronous I/O. As we all know, the performance of the USB ports on consumer routers is quite abysmal since there's no dedicated USB IC (remember, consumer routers are designed with the everything-on-a-single-chip concept in mind) for I/O offloading. USB is also horrible when it comes to asynchronous I/O in general. Here's a great thread showing just how horrible USB speeds are on consumer routers, and that's with synchronous I/O.

    You can read about squid's memory requirements and then, hopefully, reach the same conclusion I have: that what you want to do is possible, but it's going to perform horribly. Heck, given the lack of decent debugging tools on embedded devices, figuring out the performance hit will be equally as difficult. Consider that an RT-N16, which has 128MBytes of RAM, tends to use about 32MBytes. That leaves you with roughly 90MBytes for squid, which certainly isn't enough given the load (20+ simultaneously clients).

    And that's just memory. CPU is another problem, but honestly memory is going to be the bigger problem.

    Overall you would be better off with a dedicated PC acting as a caching proxy running squid, not a generic consumer router. There are x86-based devices that are the same form factor as a consumer router and provide things like 2-4GBytes of RAM, which would work a lot better in this situation.

    If you're simply asking "is this possible to do?" the answer is quite simply yes, but the performance is going to be sub-par.
  6. lancethepants

    lancethepants Network Guru Member

    I think a lot depends on the bandwidth of the places this will be in use. Disk I/O is good enough to stream 1080p movies perfectly fine. I've enjoyed taking the router to its limits. I've installed nginx + php + mysql in one setup. In another I've done sabnzbd + sickbeard. <- Very intensive setup, especially when unpacking/repairing files.

    I would say 6-7MB/s usb transfer + cache, would definitely be better than places with 1mb/s or less for many connections. When it comes to performance, these routers always will perform "sub-par" compared to their x86 counterparts, it just really depends how much sub-par. Enough to void the feasibility of running squid? I don't think so. It would be interesting to see some test results though. I've known individuals that have gone to 3rd countries for humanitarian work. Many times, if they have internet, we're talking slower than dial-up speeds. 20+ PCs would absolutely benefit from caching. I'm not sure what satellite internet speeds function at, but it can't be very fast.

    It seems the project of EasyTomato is to make things easy (lol). Even if a stand-alone PC is accessible, their assumption is that there will be no-one with the technical skills to make it happen. Having something should be better than having nothing. If I can download and watch high-def video from this device, and setup a respectable (caching) web application previously mentioned, I think in some 3rd World country it could handle caching a few web-sites for some kids.

    May I also suggest checking out entware.

    It's a modern optware replacement, and it does have squid.
  7. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    Lancethepants hit the nail on the head here. This is going to be setup by a local teacher in a developing country, so anything anymore complicated than putting in a USB stick and hitting go, is 100% out of the question. Beyond that, a few MB/s is going to kick the CRAP out of whatever the local connection is (VSAT, 3g, or other).

    Thanks for the entware link, we will check it out!

    Glad to hear the consensus is it can be done. One thing we don't want to have happen is people turning on the caching server if it will slow them down (faster internet connection). If we have benchmark data and know a their connection speed (we will cover this in another "brainstorming" thread about how we should automatically measure WAN throughput) we can automatically make a recommendation as to whether or not they should use the caching feature.

    We likely wont see this feature in EasyTomato until 1.0+ but this is helpful for our roadmapping. Thanks again for the thoughts.
  8. koitsu

    koitsu Network Guru Member

    Footnote comment: you also have my blessing (that came out wrong, haha. You know what I mean though) regarding Entware (re: wl500g-repo). It's really quite excellent and a huge improvement over the old (bleh) ipkg-based nonsense.

    I do have an open ticket/bug with the author of Entware regarding the installer methodology though. What goes on there is quite ugly -- it leaves leftover crap in /tmp, makes use of ipkg (...) just so it can upgrade to opkg, and so on. Functionally it works, but it's far from ideal/clean. I hope to work with the author to address all of that. But for now, just know that yes, it absolutely works and once installed is much, much better.
  9. ryzhov_al

    ryzhov_al Addicted to LI Member

    You ticket has assigned to MercuryV, but there is no any feedback from you.

    Why do you think it's too ugly? It uses shell-based ipkg manager to bootstrap native opkg package system. It works well since very repo opening.
    Please, write comment on a issue page.
  10. koitsu

    koitsu Network Guru Member

    Because there is no reason to use ipkg at all. There is no feedback because I haven't had the time to fully document a proper, effective model/method. There are multiple solutions to the problem but each of them have caveats.
  11. ryzhov_al

    ryzhov_al Addicted to LI Member

    Can't agree that. We need some tool, that can install some meta-package (by name, without version), parse its subdependencies and install it.
    Or you will have to hardcode subdeps names in script like DD-WRT do, or (most brutal way) pack basic libraries + opkg and unpack it at bootstrap.
    It must be a shell script because any binary may fail in a such hostile environment.

    Thats why we use Thats why use it too. Is there any better way?
  12. koitsu

    koitsu Network Guru Member

    Yes, there is a better way. And it has nothing to do with this thread, so if you wish to discuss it, we can discuss it privately or elsewhere (in the Google Code ticket?). Trying to keep this thread on topic.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice