Here's a quick attempt at the same thing in Java (although note that the command line format is different): https://gist.github.com/tomwhoiscontrary/b4888b86057c74a636c... The main takeaway is that the JDK's built-in web server is poor: * There is no way to configure timeouts * Filters have to be added to each handler separately, by mucking with its filter list * Filters have to extend an abstract class with two meth…
If you're using java, just use finagle's http server and be done with it. It is really good and runs most all of twitter.com's production web services. The very definition of "web scale": https://twitter.github.io/finagle/guide/Quickstart.html
Show HN: A simple Go web server with logging, tracing, health check
71–80 of 97 posts
Re: Show HN: A simple Go web server with logging, tracing, health check
#72Earlier quoted context omitted.
If you're using java, just use finagle's http server and be done with it. It is really good and runs most all of twitter.com's production web services. The very definition of "web scale": https://twitter.github.io/finagle/guide/Quickstart.html
Not sure if I would use Twitter as a success story for handling scale. Not exactly the poster boy of reliable software.
Pick two.
Re: Show HN: A simple Go web server with logging, tracing, health check
#73This reminds me of an ongoing discussion I was having with friends about Golang web frameworks -- one side of the argument is that you can achieve so much with the standard library that frameworks are "unnecessary", but folk like me want an ORM(ish) layer and some kind of back-office scaffolding. https://beego.me and https://iris-go.com are nice, but we (all) have (as yet) to find a Django-like framework that comes w…
Re: Show HN: A simple Go web server with logging, tracing, health check
#74Earlier quoted context omitted.
If you're using java, just use finagle's http server and be done with it. It is really good and runs most all of twitter.com's production web services. The very definition of "web scale": https://twitter.github.io/finagle/guide/Quickstart.html
Not sure if I would use Twitter as a success story for handling scale. Not exactly the poster boy of reliable software.
Twitter, Soundcloud, Salesforce, Pinterest, FitBit, Tumblr, Box, Foursquare... What do they all have in common? They all run finagle in production. For java, it is about as battletested and as good as you'll get unless you want to write your own. Personally, I'm more of a golang and python developer, but respect where it is due. Twitter is massively more scalable than the overwhelmingly majority of the sites on the internet and they've gotten their act together since abandoning Ruby and the fail whale.
Re: Show HN: A simple Go web server with logging, tracing, health check
#75Earlier quoted context omitted.
What do you mean by small scale? I think requests per second. Our Go-backed API has handled 90k rps without batting an eye. Or do you mean small scale as in team size? It is my understanding that Go was specifically designed to work for large organizations ( cough Google cough ). Or do you mean single page JavaScript web sites? At which point Go would be the backing API? I don't see what qualifies Go for "small scale…
A small scale means you won't use redis for in memory data storage. You will not need C++ to write heavy string processing and hash table lookup. Golang also doesn't scale well if you have some heavy processing involving trees( http://benchmarksgame.alioth.debian.org/u64q/binarytrees.htm... ).
Go was not designed for the small scale, but the large:
- it has a sensible module system that makes compilation fast
- it's a simple language that encourages boring code - your coworkers will probably write code that works and that you can maintain
- Multithreading is a first class concept. Programs you build locally using typical patterns scale when you run them on massive multi-core servers
- the language is memory safe by default
C++ projects require experts to build, scale and maintain. Go is designed to give that capability to journeyman developers.
Yes C++ is generally going to be faster, but rarely do people talk about why that is. It usually comes down to: a smarter compiler, unsafe operations, or clever optimization. The first is legitimate, but rarely that significant. The second is a penalty that's usually worth keeping (you want bounds checking on arrays), and the third misses the point.
Sure the expert c++ developer could write faster code, but is that who you have? Are you going to take the time to do all that optimization work?
Re: Show HN: A simple Go web server with logging, tracing, health check
#76This reminds me of an ongoing discussion I was having with friends about Golang web frameworks -- one side of the argument is that you can achieve so much with the standard library that frameworks are "unnecessary", but folk like me want an ORM(ish) layer and some kind of back-office scaffolding. https://beego.me and https://iris-go.com are nice, but we (all) have (as yet) to find a Django-like framework that comes w…
Re: Show HN: A simple Go web server with logging, tracing, health check
#77This reminds me of an ongoing discussion I was having with friends about Golang web frameworks -- one side of the argument is that you can achieve so much with the standard library that frameworks are "unnecessary", but folk like me want an ORM(ish) layer and some kind of back-office scaffolding. https://beego.me and https://iris-go.com are nice, but we (all) have (as yet) to find a Django-like framework that comes w…
I regularly go down this road with go. My conclusion is that it's never going to suit that use case. I'm not even sure it's not technically doable (i think introspection and interface{} can go quite far), but it's just culturally opposed to this kind of project. People like go for its minimalist approach. Not in the sense that you don't have a lot of code to write, but more in the sense that you are in control of eve…
Mostly agree except for code-gen --- definitely not so in the real world! I'd say most Gophers on the whole at a minimum don't mind it, and many either outright ---or eventually--- embrace it.
Depends on the nature and purpose(s) of the Go code-base but for many, it's as natural and idiomatic as is the extensive use of the macro preprocessor for many-perhaps-most grown, matured, "non-trivial" C code-bases. (Just fewer pitfalls in exchange for a bit more set-up effort.)
Re: Show HN: A simple Go web server with logging, tracing, health check
#78This reminds me of an ongoing discussion I was having with friends about Golang web frameworks -- one side of the argument is that you can achieve so much with the standard library that frameworks are "unnecessary", but folk like me want an ORM(ish) layer and some kind of back-office scaffolding. https://beego.me and https://iris-go.com are nice, but we (all) have (as yet) to find a Django-like framework that comes w…
I regularly go down this road with go. My conclusion is that it's never going to suit that use case. I'm not even sure it's not technically doable (i think introspection and interface{} can go quite far), but it's just culturally opposed to this kind of project. People like go for its minimalist approach. Not in the sense that you don't have a lot of code to write, but more in the sense that you are in control of eve…
Elixir is close to my ideal though I like static types and a better community around libs would be nice.
Re: Show HN: A simple Go web server with logging, tracing, health check
#79Earlier quoted context omitted.
I disagree, I will always prefer projects with the least dependencies given two options with the same feature set. We should always try to strive to lower dependencies when it makes sense.
> We should always try to strive to lower dependencies when it makes sense. Maybe, but I think 'when it makes sense', might be 'rarely'. There a 2 ways to avoid dependencies: 1. lean on a batteries-included standard lib as this gist does or 2. write it yourself. Problem with 1. is standard lib libraries aren't always great, see 'where modules go to die' [1], (examples: httplib/urllib in Python, or the string librarie…
I only use the stldlib in Go, and a few packages (like google/uuid) that will become part of the stdlib at some point.
I know exactly what my program is doing, and why.
In Node, I would often hit 100+ dependencies before getting to the actual meat of the thing, and if there was a problem I had no idea where to look in the mess of other people's code. Given the number of PR's on the average node module, and the number of dependencies, I was guaranteed to be importing bugs every time I used an external module. Whether I hit one of those bugs and had to deal with it was a matter of luck. Dealing with bugs in someone else's library is a million times worse than writing the code myself.
Re: Show HN: A simple Go web server with logging, tracing, health check
#80Here's a quick attempt at the same thing in Java (although note that the command line format is different): https://gist.github.com/tomwhoiscontrary/b4888b86057c74a636c... The main takeaway is that the JDK's built-in web server is poor: * There is no way to configure timeouts * Filters have to be added to each handler separately, by mucking with its filter list * Filters have to extend an abstract class with two meth…
Nice. Does anyone have a server like this but with the addition of * serving of files and directories * LetsEncrypt certificates and SSL
package main
import (
"fmt"
"net/http"
"path/filepath"
)
var (
host = "0.0.0.0"
path = "/var/www/public"
port = 8080
)
func main() {
path, err := filepath.Abs(path)
if err != nil {
panic(err)
}
listenAt := fmt.Sprintf("%s:%v", host, port)
fmt.Println("static-serve-dir serving", path, "over http at", listenAt)
err = http.ListenAndServe(listenAt, http.FileServer(http.Dir(path)))
if err != nil {
panic(err)
}
}