Joint optimization of hardware and network costs for distributed computer systems