When both MicroProfile and Istio Fault Tolerance capabilities are enabled, there is a compounding effect that may be unexpected.
If both MicroProfile and Istio set their own Retry policies on a service,
the maximum number of retries that occur is not equivalent to either of the number of retries specified in MicroProfile or Istio.
The number of retries set by MicroProfile and Istio are actually multiplied.
If you want to use Istio as your service mesh and only its fault tolerance capabilities,
you can turn off MicroProfile Fault Tolerance by adding a property. This configuration avoids any overlap in behaviours.
MicroProfile Fault Tolerance offers a config property MP_Fault_Tolerance_NonFallback_Enabled
that disables all
MicroProfile Fault Tolerance capabilities except fallback. If MP_Fault_Tolerance_NonFallback_Enabled
is set to false, only
the @Fallback
behaviour is enabled. The other behaviours specified by the MicroProfile Fault Tolerance annotations,
including @Retry
, won’t take effect.
You will define the MP_Fault_Tolerance_NonFallback_Enabled
config property in a ConfigMap.
ConfigMaps store configuration settings about a Kubernetes pod. This configuration is loaded into the pod as an environment variable that is
used by the pod’s containers. The environment variables are defined in the pod’s specification by using the envFrom
field. To learn more about ConfigMaps,
check out the Configuring microservices running in Kubernetes guide.
Use the MP_Fault_Tolerance_NonFallback_Enabled
config property to disable the retries performed by MicroProfile,
so that only Istio performs retries.
Update the services.yaml file.
Add a ConfigMap
into the services.yaml
file, and
set the MP_Fault_Tolerance_NonFallback_Enabled
config property to false.
Add the envFrom
field
to inject the ConfigMap
with the MP_Fault_Tolerance_NonFallback_Enabled
property into your pods.
The name
of the ConfigMap
, which is inventory-config
,
becomes the environment variable name
that is specified in the envFrom
field.
Deploy your microservices again to turn off all MicroProfile Fault Tolerance capabilities, except fallback:
Wait until all of your deployments are ready and available.
Run the kubectl get pods
command to get the new [system-pod-name]
.
Pause the system
service pod to simulate that the service is unavailable:
Make a request to the service by using curl
:
If the curl
command is unavailable, then use Postman.
Because the system
service is unavailable, the request still returns a 503
response code.
This time, however, the request was retried several times with Istio, without any retries from MicroProfile.
See the number of times that the service was retried:
You will see the following output:
This command returns 5, indicating that a total of 5 requests were made to the system
service.
Because MicroProfile’s Retry policy is disabled, only Istio’s retries are performed.