Skip to content

Instantly share code, notes, and snippets.

@typewriter
Created May 21, 2021 12:49
Show Gist options
  • Save typewriter/ec31ad362315af9f9e89b413c6cf1b43 to your computer and use it in GitHub Desktop.
Save typewriter/ec31ad362315af9f9e89b413c6cf1b43 to your computer and use it in GitHub Desktop.
GCP Cloud Run と AWS App Runner のスケーリングの様子をみる
FROM golang:latest as builder
WORKDIR /opt/server
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o app main.go
FROM alpine:latest
EXPOSE 8080
COPY --from=builder /opt/server/app /opt/server/app
CMD ["/opt/server/app"]
module server
go 1.16
#!/bin/bash
URL=$1
while true
do
printf '%(%H:%M:%S)T: '
curl -s $URL -w ", time: %{time_starttransfer} s\n"
done
package main
import (
"fmt"
"net/http"
"os"
"time"
)
func handler(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Second * 1)
fmt.Fprintf(w, "%#v", os.Environ())
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment