I am saving a mongo document using mongotemplate in java spring boot. But sometimes it is taking time to save the document. usually it is taking 2 Min to save the document. I have checked in the mongo server graphs, during that time pageout seems to be increase. I am having t2.medium aws server. Graph Reference of mongo db server is attached(See the Page OUT spike 13376). please suggest what should I do to sort this page OUT issue...
below is the java code to save the document:
public <T extends BaseMongoEntity> T save(T objectToSave) {
return mongoTemplate.save(objectToSave);
}
Below is mongo entity:
@Data
@Document(collection = MDBCollection.WALLET_TRANSACTION)
public class WalletTransactionRequest extends BaseMongoEntity {
@Serial
private static final long serialVersionUID = 2773733474298691321L;
private String orderCode;
private String awbNo;
private String tenantCode;
private List<OperationRequest> operationRequestList = new ArrayList<>();
private boolean preValidateBalance = false;
@Data
public static class OperationRequest{
BigDecimal amount;
BigDecimal gstAmount;
WalletOperation walletOperation;
public OperationRequest(BigDecimal amount,BigDecimal gstAmount, WalletOperation walletOperation) {
Objects.requireNonNull(gstAmount, "GST rate cannot be null");
this.amount = amount;
this.gstAmount = gstAmount;
this.walletOperation = walletOperation;
}
}
public void addOperation(OperationRequest operationRequest){
this.operationRequestList.add(operationRequest);
}
public WalletTransactionRequest(String orderCode, String awbNo, String tenantCode) {
this.orderCode = orderCode;
this.awbNo = awbNo;
this.tenantCode = tenantCode;
}
}