News for hackers. Stuff that matters.
Re:So you want to expose Go on the Internet by weberc2 on Monday December 19, 2016 @05:02PM (#13215368)
Given that Go's HTTP interfaces are very composable, and assuming there are libraries to do caching and traffic splitting, you wouldn't be reinventing wheels. At that point, it seems that the question is whether you prefer to manage NGINX config files or write your configuration in Go.
Re:So you want to expose Go on the Internet by nkozyra on Monday December 19, 2016 @05:12PM (#13215443)
OK, so 're-implement' the wheel. Using a variety of unrelated, dubiously-updated libraries.

I'm still not sure what the advantage of that is over using perhaps the most reliable, certainly most-used web server as a proxy in front of your app. I'm open to convincing, though.

Re:So you want to expose Go on the Internet by weberc2 on Monday December 19, 2016 @06:56PM (#13216123)
How is filling out struct fields more complex than filling out config files? The principle advantage is system simplicity--everything deploys in a single file, no network topology to troubleshoot, fewer moving parts, no new highly-configurable tool to master. If the quality of those libraries is as poor as you suppose, then take NGINX by all means. I don't see any reason to make those assumptions, however.

I don't mean to overstate the advantages--I think both solutions are fine; neither will make or break your operation.

Re:So you want to expose Go on the Internet by nkozyra on Monday December 19, 2016 @07:58PM (#13216446)
It's more than filling out a few structs, though. Traffic splitting or caching via NGINX can literally be done in a handful of lines. No go gets, no middleware and it's well tested, mature and backed by software that powers a majority of the web.

I use go net/http every day, in production. I trust it, but NGINX provides so much more battle tested functionality out of the box.

Re:So you want to expose Go on the Internet by weberc2 on Monday December 19, 2016 @09:29PM (#13216918)
> It's more than filling out a few structs, though.

How do you know how many lines are required to configure hypothetical middleware?

> No go gets

How is static compilation worse than `apt-get install` or `docker run`?

> No middleware

It's another process... why would running another process be better than middleware?

> it's well tested, mature and backed by software that powers a majority of the web.

Granted. It seems like this is the only clear win for NGINX, and it may well change if Go libraries mature. Time will tell.

Re:So you want to expose Go on the Internet by 234dd57d2c8db on Monday December 19, 2016 @11:35PM (#13217489)
You're missing the sysadmin angle of this entirely. Nginx has amazing tooling around load balancing, configuration mgmt, multiple languages, logging options, rewrite rules, rate limiting, file upload size tuning, HTTP tuning in general, the list goes on and on. What if your site needs to support multiple backends like a JVM app, a wsgi app, and an old crufty cgi app. You gonna write backends for all that shit too in Go?

Sorry but I'm not going to be writing ansible code that modifies structs inside of some program then compiles said program. No thank you that sounds like crazy town. Also other sysadmins and infrastructure engineers will actually know how things work and won't have to go reading the source code for some crazy Go app program at 2am that also is a webserver for some reason?

Separation of concerns, use it!!

Re:So you want to expose Go on the Internet by weberc2 on Tuesday December 20, 2016 @10:06AM (#13220389)
> You gonna write backends for all that shit too in Go?

The discussion is scoped to a single Go application. No one is proposing replacing NGINX with Go (or anything else) for JVM apps.

> won't have to go reading the source code for some crazy Go app program at 2am that also is a webserver for some reason?

This is a rephrasing of the question I posed earlier--is it easier to manage configuration in Go source code or NGINX config files.

> Separation of concerns, use it!!

Concerns can be separated without being in distinct processes or implemented by distinct programmers or implemented in distinct programming languages.

Re:So you want to expose Go on the Internet by Can_Not on Friday December 23, 2016 @09:56AM (#13244992)
You're free to not use nginx or Apache if you can validate that you are better off without them, but IMHO it sounds like a nightmare of "experimental homemade wheels" being muddled in with business logic.
Re:So you want to expose Go on the Internet by nkozyra on Monday December 19, 2016 @10:06PM (#13217094)
> How do you know how many lines are required to configure hypothetical middleware?

Primarily through experience. Happy to be shown otherwise. Middleware usually takes a bit more configuration than that.

> Granted. It seems like this is the only clear win for NGINX, and it may well change if Go libraries mature. Time will tell.

We can quibble over whether it's the "only" win, but even so, it's a very, very big win. It's a single point of failure that handles a lot of features you'd have to replicate with various packages that lack the kind of support, maturity and community that NGINX has.

Re:So you want to expose Go on the Internet by throwaw12ay on Tuesday December 20, 2016 @11:40AM (#13221394)
> How is filling out struct fields more complex

It's also about reproducing all the business logic provided by nginx, not just configuration. You can't pretend like net/http package gives you everything ngnix provides, that's a lie.

Re:So you want to expose Go on the Internet by paulddraper on Monday December 19, 2016 @05:40PM (#13215659)
> whether you prefer to manage NGINX config files or write your configuration in Go

When it comes to these decisions, I use the Principal of Least Power (https://en.wikipedia.org/wiki/Rule_of_least_power)

If writing

    proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g

    location / {
        proxy_cache my_cache;
        proxy_pass http://my_upstream;
    }
gets me what I want without Turing-completeness, I'll choose that.

Obviously, more complicated tasks require more complicated tools.

Re:So you want to expose Go on the Internet by weberc2 on Monday December 19, 2016 @06:43PM (#13216039)
I agree, when choosing between two configuration languages all else equal, choose the one with the least power. However, I think there are some advantages to choosing Go that might offset this rule--specifically simpler deployment and process topology. Further, if you know Go and not NGINX, the learning curve is (probably) better as well.
Re:So you want to expose Go on the Internet by solidsnack9000 on Tuesday December 20, 2016 @12:31AM (#13217710)
> ...if you know Go and not NGINX...

This doesn't seem like a solid basis for making engineering decisions -- or any kind of decisions.

Re:So you want to expose Go on the Internet by lox on Tuesday December 20, 2016 @03:51AM (#13218394)
On the contrary, it makes a lot more sense to build something in technology you have expertise in than it does to "use the right tool for the job". I'd rather have less tools to maintain at the expense of them being slightly worse fits.
Re:So you want to expose Go on the Internet by solidsnack9000 on Tuesday December 20, 2016 @05:31AM (#13218758)
What I am referring to, is thinking that it is good to not know anything about the alternatives available to you and still make a decision.

This doesn't always lead to the best decisions -- although by chance it can work out okay -- and it also has the effect of limiting your horizons. Now I can't say one should learn about every single web server out there, but when the choice is between a dedicated web server and a library in a particular programming language, there is really a lot to see on the other side. Rewrite rules and the wide variety of HTTP stats available for logging are both areas where web servers can give us new ideas.

When I was much younger I thought, why learn databases? I can use Java, I know XML. Just open the XML file and add the records. There's XQuery for searching... The historical precursor for "Why not write everything in Go?" is "Why not write everything in Java?".

Re:So you want to expose Go on the Internet by weberc2 on Tuesday December 20, 2016 @10:08AM (#13220398)
> What I am referring to, is thinking that it is good to not know anything about the alternatives available to you and still make a decision.

I think you can know enough about an alternative to decide whether or not its appropriate without conquering its learning curve.

Re:So you want to expose Go on the Internet by solidsnack9000 on Tuesday December 20, 2016 @12:51PM (#13222134)
> > What I am referring to, is thinking that it is good to not know anything about the alternatives available to you and still make a decision.

> I think you can know enough about an alternative to decide whether or not its appropriate without conquering its learning curve.

Yeah, but that's not the same thing as using your level of knowledge as the deciding factor.

Re:So you want to expose Go on the Internet by throwaw12ay on Tuesday December 20, 2016 @11:43AM (#13221435)
What you say makes no sense whatsoever. Go doesn't come with a copy of nginx in its standard library. Go std lib is not equivalent to what ngnix provides. You gophers are so obsessed by doing everything with Go it's unbelievable. Go is a tool,just like nginx, it's not a silver bullet.
Re:So you want to expose Go on the Internet by lox on Wednesday December 21, 2016 @05:42AM (#13228156)
Absolutely, but one tool is better than two tools. If it's good enough for most cases, then great, stick with the std library. It makes testing it and deploying it easier. When it gets more complicated, add Nginx.