Save 37% off PRO during our Black Friday Sale! »

Goサーバをあえて不安定にするパッケージを作った話

 Goサーバをあえて不安定にするパッケージを作った話

Go(Un)Conference(Goあんこ)LT大会 5kg

https://gounconference.connpass.com/event/112942/

9ec2ceee3f782e64fd67fa7d82b6c1b4?s=128

Hazumi Ichijo

January 31, 2019
Tweet

Transcript

  1. ©2018 Wantedly, Inc. GoαʔόΛෆ҆ఆʹ͢Δ ύοέʔδΛ࡞ͬͨ࿩ 31.Jan.2019 - Hazumi Ichijo

  2. ©2018 Wantedly, Inc. ࣗݾ঺հ Ұᑍ୺੅!IB[VNJSS!SFSPTU 4FSWFS4JEF&OHJOFFSJO8BOUFEMZ (P 3BJMT 3FBDUʜ ग़਎๺ւಓ

  3. ©2018 Wantedly, Inc. མͪͯͯ΋ྑ͍αʔϏε ϝΠϯͷαʔϏε Ϣʔβʔ

  4. ©2018 Wantedly, Inc. མͪͯͯ΋ྑ͍αʔϏε ϝΠϯͷαʔϏε Ϣʔβʔ མͪͯͯ΋ྑ͍αʔϏε ϝΠϯͷαʔϏε Ϣʔβʔ

  5. ©2018 Wantedly, Inc. མͪͯͯ΋ྑ͍αʔϏε ϝΠϯͷαʔϏε Ϣʔβʔ མͪͯ΋Өڹ͕ग़ͳ͍Α͏ʹ͢ΔͨΊʹɺ $JSDVJU#SFBLFSͱ͍͏΋ͷ͕ଘࡏ͢Δ  IUUQTHJUIVCDPNTPOZHPCSFBLFS

     IUUQTHJUIVCDPNSVCZJTUDJSDVJUCSFBLFS
  6. ©2018 Wantedly, Inc. CircuitBreaker͕ຊ౰ʹ͏·͘ಈ͔͘ෆ҆ => ಈ͔͚ͩ͘γϡοͱ֬ೝ͍ͨ͠

  7. ©2018 Wantedly, Inc.  Ͳ͏΍ͬͯෆ҆ఆʹ͢Δ͔ w ίʔυ಺ʹQBOJDͱ͔ΛೖΕΔʁ  Ͳ͏͍ͬͨৼΔ෣͍Λ͢Δ΂͖͔ w

    ൪୆Λฦ͢ʁϨεϙϯεΛ஗͘͢Δʁ
  8. ©2018 Wantedly, Inc. Ͳ͏΍ͬͯෆ҆ఆʹ͢Δ͔ Ϣʔβʔ ϝΠϯͷαʔό͔Βݟ͑Δͷ͸ Ϩεϙϯε͚ͩ IUUQH31$

  9. ©2018 Wantedly, Inc. Ͳ͏΍ͬͯෆ҆ఆʹ͢Δ͔ Ϣʔβʔ ͚ͩ͜͜ʹෆ҆ఆ͞Λ͍ΕΕ͹͍͍

  10. ©2018 Wantedly, Inc. Ͳ͏΍ͬͯෆ҆ఆʹ͢Δ͔ Ϣʔβʔ H31$*OUFSDFQUPS IUUQ.JEEMFXBSF

  11. ©2018 Wantedly, Inc. Ͳ͏͍ͬͨৼΔ෣͍Λ͢΂͖͔ https://engineering.linkedin.com/blog/2018/05/linkedout--a-request-level-failure-injection-framework -JOLFEJOͷ'BJMVSF*OKFDUJPO'SBNFXPSLͰ͸ w &SSPS w %FMBZ

    w 5JNFPVU ͷͭΛೖΕ͍ͯΔ
  12. ©2018 Wantedly, Inc. Ͳ͏͍ͬͨৼΔ෣͍Λ͢΂͖͔ https://engineering.linkedin.com/blog/2018/05/linkedout--a-request-level-failure-injection-framework -JOLFEJOͷ'BJMVSF*OKFDUJPO'SBNFXPSLͰ͸ w &SSPS w %FMBZ

    w 5JNFPVU ͷͭΛೖΕ͍ͯΔ ͦͷ͏ͪɺ&SSPSɾ5JNFPVU͕͋Ε͹ࢼͤͦ͏ɻ ߋʹɺͦ͏͍ͬͨৼΔ෣͍͸ϥϯμϜʹى͖ΔΑ͏ʹ͍ͨ͠ αʔϏεΛ6OJY5JNF͕/ͰׂΓ੾ΕΔͱ͖ΞϗʹͳΔΑ͏ʹ͢Ε͹ྑ͛͞
  13. ©2018 Wantedly, Inc. Ͳ͏͍ͬͨৼΔ෣͍Λ͢΂͖͔ { "interval": 1, "slow_response_option": { "enable":

    true, "time": 5 }, "server_error_option": { "enable": true } }
  14. ©2018 Wantedly, Inc. ͦ͏͍ͬͨύοέʔδΛ࡞੒ͨ͠ https://github.com/rerost/unstable

  15. ©2018 Wantedly, Inc. package main import ( "fmt" "net/http" "github.com/rerost/unstable/uhttp"

    ) func main() { http.Handle("/", uhttp.WithUnstable(handler)) if err := http.ListenAndServe(":3000", nil); err != nil { fmt.Println(err) } } func handler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Sample")) }
  16. ©2018 Wantedly, Inc. package main import ( "context" "log" "net"

    "github.com/golang/protobuf/ptypes/empty" api_pb "github.com/rerost/unstable/example/grpc/server/api" "github.com/rerost/unstable/ugrpc" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) type server struct{} func (s *server) GetSample(ctx context.Context, req *empty.Empty) (*api_pb.GetSampleResponse, error) { return &api_pb.GetSampleResponse{Message: "Sample"}, nil } func main() { l, err := net.Listen("tcp", ":5000") if err != nil { log.Fatalf("Failed to listen: %v", err) } s := grpc.NewServer( grpc.UnaryInterceptor(ugrpc.UnstableUnaryServerInterceptor()), ) api_pb.RegisterSampleServiceServer(s, &server{}) reflection.Register(s) if err := s.Serve(l); err != nil { log.Fatalf("Failed to serve: %v", err) } }
  17. ©2018 Wantedly, Inc. Demo

  18. ©2018 Wantedly, Inc.  γϡοͱ'BVMU*OKFDUJPO͍ͨ͠ͱ͖ʹ͓͢͢Ί  $IBPT&OHJOFFSJOHͱ͔͸૝ఆ͍ͯ͠ͳ͍