microservices-demo/src/productcatalogservice
Ahmet Alp Balkan a9e95bc05c
Move to go modules (#410)
Simplifies and modernizes the go build process.
Old vs new build times (without cache):

- frontend: 185s vs 33s.
- productcatalog: 190s vs 30s.
- shippingservice: 200s vs 36s.
- checkoutservice: 129s vs 27s.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2020-10-13 13:05:53 -07:00
..
genproto Add licenses (#367) 2020-07-15 11:56:37 -07:00
.dockerignore go: use dep in builds, remove relative imports 2018-08-04 11:21:03 -07:00
Dockerfile Move to go modules (#410) 2020-10-13 13:05:53 -07:00
README.md productcatalog: introduce configurable latency (#134) 2019-01-29 16:08:24 -08:00
genproto.sh Add more license headers 2018-07-25 21:25:27 -07:00
go.mod Move to go modules (#410) 2020-10-13 13:05:53 -07:00
go.sum Move to go modules (#410) 2020-10-13 13:05:53 -07:00
products.json Rebrand Hipstershop as OnlineBoutique (#328) 2020-04-23 14:12:30 -07:00
server.go Updated deps for exporter/jaeger (#282) 2020-04-13 15:23:46 -07:00
server_test.go go: use dep in builds, remove relative imports 2018-08-04 11:21:03 -07:00

README.md

productcatalogservice

Run the following command to restore dependencies to vendor/ directory:

dep ensure --vendor-only

Dynamic catalog reloading / artificial delay

This service has a "dynamic catalog reloading" feature that is purposefully not well implemented. The goal of this feature is to allow you to modify the products.json file and have the changes be picked up without having to restart the service.

However, this feature is bugged: the catalog is actually reloaded on each request, introducing a noticeable delay in the frontend. This delay will also show up in profiling tools: the parseCatalog function will take more than 80% of the CPU time.

You can trigger this feature (and the delay) by sending a USR1 signal and remove it (if needed) by sending a USR2 signal:

# Trigger bug
kubectl exec \
    $(kubectl get pods -l app=productcatalogservice -o jsonpath='{.items[0].metadata.name}') \
    -c server -- kill -USR1 1
# Remove bug
kubectl exec \
    $(kubectl get pods -l app=productcatalogservice -o jsonpath='{.items[0].metadata.name}') \
    -c server -- kill -USR2 1

Latency injection

This service has an EXTRA_LATENCY environment variable. This will inject a sleep for the specified time.Duration on every call to to the server.

For example, use EXTRA_LATENCY="5.5s" to sleep for 5.5 seconds on every request.