This paper presents a practical methodology for optimizing pile group design of bridge foundation. A code-based method is used to design and analyze piled foundation. Then, a mathematical model for optimizing the problem by a real genetic algorithm is established with the direct total cost of pile foundation as the objective function. The global optimal solution (GOS) is first found by the exhaustive searching method (ESM). The GOS is a base for verifying the performance of different searching methods. The real genetic algorithm (RGA) is then proposed to globally search the optimal solution in a much little time than ESM. Seven real design cases are used to test the performance of RGA. Static penalty method (SPM) and Death penalty method (DPM) are used to treat constrained functions in the RGA used in the study. The analysis results show that the RGA can obtain the solutions within 48-61 minutes which are only about 1/1,000 of the time spent by the ESM. The construction costs of those solutions only differ from those of the global minimum solutions by 1.62-2.0% in average, and the minimum cost one of the solutions is the same as the global minimum solution. Thus, the proposed optimization methodology is time-efficient and technically practicable to be used in daily engineering works.