Optimize merges small files into larger ones and can involve shuffling and creation of large in-memory partitions. Thus its recommended to use a memory optimized executor configuration to prevent spilling to disk. IN additional use of autoscaling will also help with adapting to spikes in data volume
It is also recommended that you use a separate jobs cluster if possible to run optimize so as to no impact the performance of other jobs