Well, technically, it doesn't really matter that much if a certain % of the GDP is spent on military instead of public works, as long as you are purchasing from local buyers. All the money spent on military equipment is going from your budget back into your economy to pay for the services required to produce that equipment. Engineers, technicians, electricians, scientists of many fields, as well as local businesses are kept employed and paid this way. You can pay an aeronautical engineer to develop you an attack aircraft or you can redirect those funds and pay a civil engineer to develop you a metro train. Either way, somebody in the country is employed and paid.
Unlike many other countries, Russia has a very large share in global weapons exports, thus imo their defense spendings are sustainable.