One of the main structural elements of metalworking machines is the spindle assembly (spindle), which is used to hold cutting tools or workpieces. The rigidity of the spindle assembly plays a decisive role in ensuring the accuracy and efficiency of the machine as a whole. The assessment of the spindle shaft stiffness is carried out on the basis of the analysis of the static bending of the spindle shaft, which made it possible to formulate and solve the problems of optimizing the spindle shaft according to the stiffness characteristics for two supporting structures on nonlinear elastic supports. To determine the stiffness of roller bearings, the work uses the dependence obtained on the basis of solving the problem of contact interaction of an elastic steel cylinder with curvilinear elastic steel half-spaces. For the considered design scheme, the optimization goals were chosen for the conditions of the smallest displacement of the end section of the spindle shaft console, the achievement of the minimum angle of rotation in this section or the minimum of their normalized superposition, which ensures maximum rigidity in the processing zone. Consideration has also been given to minimizing the swing angle at the front support to maximize bearing life. Mathematically, the problem is presented in the form of minimizing one of the 4 proposed objective functions by changing the variable parameters - the length of the cantilever and the value of the inter-support distance, represented as dimensionless quantities - the cantilever coefficient and the inter-support distance coefficient. Minimum and maximum values of the cantilever length and shaft span were considered as constraints on the variable parameters. Varying the console coefficients and the inter-support distance was carried out by the method of sequential enumeration within the specified constraints, the solution of optimization problems is presented in a graphical form. The solution to the problem of shaft bending was carried out on the basis of the equation of the bent axis of the beam in the framework of the Euler - Bernoulli hypotheses and presented in an analytical form together with analytical dependencies for calculating the radial stiffness of a roller bearing as a function of the supporting force acting on it. The algorithm for solving optimization problems is implemented in the MatLAB package. Optimal solutions have shown that the minimum of the combined functions, consisting of the sum of the relative deflection values at the end of the console and the angles of rotation at the end of the console and on the front support, is achieved at the same variable parameters as the minima of the angles of rotation at the end of the console and on the front support. The proposed approach to the design of the shafts of spindle units of metal-cutting machines, which are optimal in terms of rigidity characteristics, forms a tool for a reasonable choice of bearings and design parameters of spindle shafts.