Update, after running this program several times the 112mb/sec number is limited by how quickly the file could be streamed off disk. Once the source file was cached, the time to upload 7.4 gb dropped to around 3 seconds, so ~ 2.5 gb / sec, which is more reasonable for the loopback.
What do you see on your system with a similar sized file? On Tuesday, 27 June 2017 12:08:19 UTC+10, Dave Cheney wrote: > > Hi Kai, > > I had a quick play with this simple server > > https://play.golang.org/p/LFx0HmXK4q > > This simple server took 67 seconds to upload a 7.4gb file over the > loopback interface, which is around 112 mb per second, which is faster than > what you are seeing, but not that fast either, given it's on the loopback. > > Neither curl or the upload process used more than 10% cpu. > > deadwood(~) % time curl --tr-encoding -X POST -v -# -o output -T > ~/Downloads/nanopi-air-eflasher-sd8g-20161213.img http://local > host:8080/ > * Trying 127.0.0.1... > * Connected to localhost (127.0.0.1) port 8080 (#0) > > POST /nanopi-air-eflasher-sd8g-20161213.img HTTP/1.1 > > Host: localhost:8080 > > User-Agent: curl/7.47.0 > > Accept: */* > > Connection: TE > > TE: gzip > > Content-Length: 7899999232 > > Expect: 100-continue > > > < HTTP/1.1 100 Continue > } [16384 bytes data] > ####################################################################### > 100.0%* We are completely uploaded and fine > ######################################################################## > 100.0%< HTTP/1.1 200 OK > < Date: Tue, 27 Jun 2017 02:05:01 GMT > < Content-Length: 2 > < Content-Type: text/plain; charset=utf-8 > < > { [2 bytes data] > Warning: Failed to create the file output: Is a directory > * Failed writing body (0 != 2) > ######################################################################## > 100.0%* Closing connection 0 > > curl: (23) Failed writing body (0 != 2) > > real 1m7.274s > user 0m0.720s > sys 0m6.348s > > > On Tuesday, 27 June 2017 11:37:30 UTC+10, Kai Hendry wrote: >> >> Hi guys, prompted by >> https://twitter.com/davecheney/status/879505821977133057 and writing in >> to ask for good examples of how to handle HTTP POST uploads simply. >> >> And when I mean simply, I mean at the same speed as PHP, 100 meg/sec on >> my Gigabit LAN. I did try some code yesterday and I was frustratingly only >> getting 5MB/s: >> https://github.com/wmark/caddy.upload/issues/24 >> >> There do indeed seem like many examples of this very common file upload >> use case [1]. Though I'm struggling to find an example that seem well >> maintained, credible (we need multipart, right?) and fast as it should be. >> >> My own use case is uploading large videos (>50M) I take from IOS to get >> them on my home server via a Web form. >> >> Thanks guys! >> >> [1] >> https://github.com/search?utf8=%E2%9C%93&q=golang+file+upload&ref=simplesearch >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.