<p>We are running one of our services in a newly created kubernetes cluster. Because of that, we have now switched them from the previous "in-memory" cache to a Redis cache.</p>

<p>Preliminary tests on our application which exposes an API shows that we experience timeouts from our applications to the Redis cache. I have no idea why and it issue pops up very irregularly.</p>

<p>So I'm thinking maybe the reason for these timeouts are actually network related. Is it a good idea to put in affinity so we always run the Redis-cache on the same nodes as the application to prevent network issues?</p>

<p>The issues have not arisen during "very high load" situations so it's concerning me a bit.</p>

PvPlatten
<p>This is an opinion question so I'll answer in an opinionated way:</p>

<p>Like you mentioned I would try to put the Redis and application pods on the same node, that would rule out <code>wire</code> networking issues. You can accomplish that with <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity" rel="nofollow noreferrer">Kubernetes pod affinity</a>. But you can also try <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector" rel="nofollow noreferrer">nodeslector</a>, that way you always pin your Redis and application pods to a specific node.</p>

<p>Another way to do this is to <a href="https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/" rel="nofollow noreferrer">taint</a> your nodes where you want to run your workloads and then add a toleration to the Redis and your application pods.</p>

<p>Hope it helps!</p>
