Closed manhnd1kp closed 5 months ago
Yes, if the number of accounts is too large, it may time out. Pagination reading can solve this problem.
Sorry, maybe my question isn't clear. I'm not asking about the API to get accounts. I want to know if the matching engine will load all accounts in the system into the variable 'accounts' in the 'AccountBook'.
private final Map<String, Map<String, Account>> accounts = new HashMap<>();
public void add(Account account) {
this.accounts.computeIfAbsent(account.getUserId(), x -> new HashMap<>())
.put(account.getCurrency(), account);
}
I'm not sure how many users you have. If there are many, just increase the memory of the matching engine. HashMap can easily handle tens of millions of data.
I see that you load all accounts from the database when you run the matching engine, right? Is it broken when you have a lot of users?