High brightness, high repetition rate electron beams are key components for optimizing the performance of next generation scientific instruments, such as MHz-class X-ray Free Electron Laser (XFEL) and Ultra-fast Electron Diffraction/Microscopy (UED/UEM). In the Advanced Photo-injector EXperiment (APEX) at Berkeley Lab, a photoelectron gun based on a 185.7 MHz normal conducting re-entrant RF cavity, has been proven to be a feasible solution to provide high brightness, high repetition rate electron beam for both XFEL and UED/UEM. Based on the success of APEX, a new electron gun system, named APEX2, has been under development to further improve the electron beam brightness. For APEX2, we have designed a new 162.5 MHz two-cell photoelectron gun and achieved a significant increase on the cathode launching field and the beam exit energy. For a fixed charge per bunch, these improvements will allow for the emittance reduction and hence to an incresed beam brightness. The design of APEX2 gun cavity is a complex problem with multiple design goals and restrictions, some even competing each other. For a systematic and comprehensive search for the optmized cavity geometry, we have developed and implemented a novel optimization method based on the Multi-Objective Genetic Algorithm (MOGA).