How long do flies live, and how long can they generally survive?

How long do flies live? A fly can survive for about 1 month in the height of summer, but at lower temperatures its lifespan can be extended by 2 to 3 months; below 10 degrees it can hardly be active at all and lives even longer.
The main factors affecting a fly's lifespan are temperature, humidity, food and water. A temperature of 25°C to 33°C and air humidity of 60% to 70% are optimal. Female flies live longer than male flies, with a lifespan of 30 to 60 days; under laboratory conditions they can live as long as 112 days, and under low-temperature overwintering conditions flies can live for as long as half a year.
Flies have the physiological trait of being able to lay eggs for life after a single mating. A female fly can lay eggs 5-6 times in her lifetime, with about 100-150 eggs each time, and up to around 300 at most. Within one year they can reproduce for 10-12 generations.