# Lightweight proxy for Raspberry Pi



## drmike (Nov 17, 2013)

Tinkering with my Raspberry Pi.   

One of the first projects is to centralize my network outbound traffic in one spot.   

Main piece there is a proxy.

I tried Squid and Privoxy.

Squid hits 40-60% of CPU at around 1600KB/s

Privoxy hits 30-40% of CPU at around the same throughput.

Config for Squid is simple and no caching or anything.  Straight in and out.

Privoxy is running the default config.

Anyone have tuning tips to reduce CPU load here and perhaps better lightweight proxy alternatives?  Goal is to also provide caching in the proxy.   Lots of redundant traffic (updates and similar).  I can't fathom the load as-is if I graft caching in with slow SD card.


----------



## Deleted (Nov 18, 2013)

Most of it is probably syscall overhead from read(), and write(), to socket calls.

You should attach strace to the process with the '-c' arguement and let it run for a few minutes, then see what it's spending time doing the most (if it's sycall load) and then optimize from there.


----------



## BuyCPanel-Kevin (Nov 18, 2013)

Have you tried PHProxy?


----------



## drmike (Nov 18, 2013)

PHPProxy won't work since this isn't web browsing one off pages, but basically anything that can be stuffed into a SOCK5 proxy or equivalent.  Includes desktop software.

@Monkburger,  I've never messed with strace, interesting new thing for me.  Here's what I am getting from a minute or two from Squid's process:



> *strace -c -p 22408 -v*
> 
> Process 22408 attached - interrupt to quit
> Process 22408 detached
> ...


66% epoll_wait

22.81% write

4.98% read

Where does one go to optimize based on these?  I am off to find info on strace and any write ups on optimization.


----------



## Deleted (Nov 18, 2013)

Try building squid without epoll to see if that helps, it should fallback to using select().. 

I think there is a command line option to switch this on the fly, but I can't remember.


----------

