While using a load balancer for a web application that works on multiple servers, should all servers contain the same data? and if not, how does the load balancer know exactly on which server the data are actually stored?
If you use a network load-balancer which just forwards/balances requests e.g. round-robin, all servers behind that NLB should contain the same data. Elsewise users will have unexpected experiences
They use proxies (reverse proxies). These proxies can, depending on the data requested, forward requests to the correct service, e.g. by context path, or databases e.g. by DB name or shard-servers.
I use Oracle. The Oracle Cloud Infrastructure Load Balancing service provides automated traffic distribution from one entry point to multiple servers reachable from your virtual cloud network (VCN). A load balancer improves resource utilization, facilitates scaling, and helps ensure high availability. https://docs.cloud.oracle.com/en-us/iaas/Content/Balance/Concepts/balanceoverview.htm. You can have just one database/backend server and many listeners on different servers.