On 18 July 2012 13:01, Andreas Bielk <
andrea...@gmail.com> wrote:
> I'm working on my first 'real' production code in Go, and so far it's
> working out great.
>
> The project is a small authentication-proxy that sits in front of
> database-instances, in the realm of thousand(s) of clients and hundred(s) of
> db-backends.
>
> The process is basicly
>
> 1) accept new connection
> 2) authenticate client and choose a backend
> 3) create connection to backend
> 4) proxy rest of session
>
> A quick prototype seems to work very well with acceptable throughput etc.
>
> However, the creation of new backend connections is somewhat costly in terms
> of latency (for various reasons),
> and most client connections is mostly very short-lived, so I would like to
> optimize for this and reuse connections.
>
> This would be very straightforward if not for the requirement that the
> window when a connections is allowed
> to be reused is small (a second or two), and should preferably be properly
> closed down if not re-used.
>
>
> So I need a cache (Destination > Connection), that is bounded (let say less
> than 10 connections per destination)
> that supports some sort of reaper who closes and removes old connections.
>
> My first pass at this quickly became a mess, especially the timeout part..