I am still pretty new to Ethereum and smart contract but for a couple of last weeks I have been developing a smart contract for a gambling website project (studying purposes).
In the smart contract I have a function (called by the manager of smart contract) that group up all winners of a jackpot, returns to them what they bet, and then also draw random prices. So for every person who entered the jackpot, there is one iteration of a big function (drawing prices, returning initial bet).
I learned the hard way that if let's say 1000 people enter the jackpot and I call the function to reward all winners it consumes more than 6 milion gas.
How do people get around this? I would be even willing to pay considerable amount of money for running this function if so many people enter (because I can charge fees and use them to pay for this) but then there is block gas limit and there is no way I can even run this function to the end at all.