The manuscript reports the simulation of an electron gun with a view to optimizing the design of radio-frequency sources. The effects of eight parameters on the beam quality were studied and optimal choices were identified. It gives numerical beam qualities in common electrostatic triode gun, and the dependences on design parameters such as electrode geometries and bias voltages to these electrodes are shown. The electron gun is used in a number of various applications as in atomic, molecular, and surface physics. The electron optics of the electron gun was simulated and optimized using electron-beam ray-tracing simulation program SIMION 3D 7.0. An electron beam of diameter 5 mm with energy of 5 keV was assumed for simulation process. Eight design parameters were identified as variable parameters in the presence of space charge. These parameters are the gap width between the emission electrode and the anode electrode, the gap width between the emission electrode and the focusing electrode. The diameter of the anode of the electron gun, and also, diameter of the focusing electrode are studied. The applied voltage to both the emission electrode and the focusing electrode are investigated. Furthermore, the influence of space charge on the electron beam envelope through the extraction region of electron source was investigated. The space charge started to have a clear influence on the electron beam envelope at currents of 10-4 A. Beam quality was significantly improved when the applied voltage to the anode electrode was optimized and found at Vanode = + 29 k V, also, voltage applied to the emission electrode was optimized and found Vemission = - 3.6 kV, and finally voltage applied to the focusing electrode, Vfoc= - 500 V. separation distance (gap between emission electrode and) = 12 mm, the diameter of the focusing electrode = 14 mm and finally the best focused point was found at a distance of 550 mm from the end of the lens system.