Using electrodes or catalytic layers that are porous increases the reactive surface area but also the distance that ions and electrons have to travel. Thicker electrodes, through their larger surface area, reduce the activation overpotential but increase the ohmic losses. There will therefore be an electrode thickness for which the voltage losses are minimal, corresponding to a maximum energy efficiency. Simple approximate relations are derived here for the value of this optimal thickness, for both Tafel and linearised Butler-Volmer kinetics. We additionally optimise the power density of Galvanic cells, the capacity of battery electrodes, and the porosity of both particulate and foam-like electrodes. For this analysis we introduce an intuitive new definition of the electrode effectiveness factor. An accurate explicit current-voltage expression, including the transition from linear to Tafel kinetics and from a single to a doubled Tafel slope, is obtained. The present analysis is limited to a configuration where ions and electrons enter and leave at opposite sides of the electrode, as in most stacks, and applies only when mass transfer effects can be neglected. These results can nonetheless be useful for optimization of various electrochemical devices including fuel cells, batteries, flow batteries, electrochemical reactors, and electrolysers.