News for hackers. Stuff that matters.
Re:How We Went from 30 Servers to 2: Go by laumars on Tuesday March 12, 2013 @06:34PM (#5365431)
Has anyone had an experience of running websites from Go; or more specifically, how you handle none-HTML content?

I've been considering porting my CMS from mod_perl to Go, but I'm not sure how you work with the other files (CSS et al). I did read somewhere that you run Go from Apache but it's not recommended.

Re:How We Went from 30 Servers to 2: Go by carbocation on Tuesday March 12, 2013 @06:38PM (#5365451)
I've just started creating toy projects in Go. I put these Go projects (and Apache, which runs older PHP projects) behind nginx.

For hosting CSS, you either generate it programmatically and send the right Header, or you can use http.FileServe from the standard library [1]. (Surely other approaches are possible, but those are the two I've played with so far.)

[1] https://code.google.com/p/go-wiki/wiki/HttpStaticFiles

Re:How We Went from 30 Servers to 2: Go by laumars on Tuesday March 12, 2013 @06:45PM (#5365490)
Thanks for that.

The issue I have is that I would prefer to keep Apache around if I can (I have a few sites - some of which I host for friends). While my web server does have a few IPs attached, I'd rather not have to buy more IPs just to separate Apache from Go.

And to be perfectly honest, I do quite like Apache. (each to their own I know, but I've had little reason to complain about it).

Re:How We Went from 30 Servers to 2: Go by carbocation on Tuesday March 12, 2013 @06:47PM (#5365507)
Right, you're describing my situation exactly.

I used to run Apache solo.

Now I run Nginx, which forwards requests to Apache or to my various go apps based on the domain name. Apache and the go apps just listen on different ports internally. The server only has 1 IP address.

Re:How We Went from 30 Servers to 2: Go by laumars on Tuesday March 12, 2013 @06:52PM (#5365537)
You are an absolute star. If I could up vote you a hundred times I would.

Thank you

Re:How We Went from 30 Servers to 2: Go by burntsushi on Tuesday March 12, 2013 @07:40PM (#5365771)
I use Apache too (it's all I've ever known), and run a few Go web apps. Everyone lives quite peacefully together. With Apache, I just set up a simple reverse proxy.

Here's an example of one I use to run my own `godoc` server:

    <VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName godoc.burntsushi.net
        ProxyPreserveHost On
        ProxyPass / http://burntsushi.net:8080/
        ProxyPassReverse / http://burntsushi.net:8080/
    </VirtualHost>
Re:How We Went from 30 Servers to 2: Go by laumars on Tuesday March 12, 2013 @08:15PM (#5365927)
Nice idea.

I might try that before dipping my toes into Nginx

Re:How We Went from 30 Servers to 2: Go by burntsushi on Tuesday March 12, 2013 @08:35PM (#5366002)
Yeah, it's a nice holdover. I keep hearing great things about Nginx though. Someday I'll have time to check it out :-)
Re:How We Went from 30 Servers to 2: Go by Kiro on Wednesday March 13, 2013 @01:10PM (#5369676)
Seems very complicated. Why not just host the CSS files statically?
Re:How We Went from 30 Servers to 2: Go by genwin on Tuesday March 12, 2013 @06:59PM (#5365573)
My website, niflet.com, is written in Go. It uses Go's web server. While in learning mode for Go I saw that others were using Nginx instead. Now that I've gone through the development process I can see why. Go's web server is basic. Things like compressing files, setting header values and other niceties you have to write yourself or look for code written by contributors [1]. It's not as bad as it sounds though. Go has a function for serving static files like CSS files, which I wrapped in a function to serve a zipped version if the client supports that.

If I had it to do over again I would still use Go's web server, as it seems to work great. My site can conservatively handle 1 million page views hourly, using a cheap box.

[1] https://groups.google.com/forum/?fromgroups=#!topic/golang-n...

Re:How We Went from 30 Servers to 2: Go by lateefj on Tuesday March 12, 2013 @09:58PM (#5366327)
I created a project for compression doing automatically doing compression and supporting a simple proxy system [1]. It is a pretty simple system but allow for dynamically doing proxy stuff and the compression is amazingly fast. I have found Go amazingly fast and stable. It being fun is just a bonus to code in.

[1] https://bitbucket.org/lateefj/httphacks