The problem of optimal clutch sizes is a central theme in life history theory. Optimal allocation of eggs is especially complicated for insects in tritrophic systems. In this study we analyze some of the processes determining clutch sizes of the thistle gallfly Urophora cardui, a monophagous tephritid fly associated with Cirsium arvense. U. cardui forms multilocular shoot galls, which vary broadly in their size and number of their gall cells. We investigate various fitness consequences of gall size. An analysis of the number of cells per gall (which is correlated with gall diameter and gall weight) showed that in U. cardui there is mutual facilitation rather than larval competition. Increasing numbers of larvae per gall led to a decreasing mortality and increasing larval weight. Larval weight in turn was positively correlated with the probability of survival to adulthood and with adult weight and fecundity. Thus, all fitness parameters measured favoured large galls. Clutch sizes in oviposition experiments were distinctly larger than the number of gall cells of field populations and in cage experiments, suggesting high mortality of eggs and/or early larval instars. There was a significant relationship between the internal structure (i.e., the size of the growing point) of the bud and clutch size, suggesting that U. cardui females are able to measure bud quality and adapt clutch sizes accordingly. Clutch size was positively correlated with the female's age at first oviposition and negatively with the number of previous ovipositions and previously laid eggs. Since the potential egg capacity per female is higher than the average number of larvae it is likely to produce during its short adult lifespan, U. cardui females tend to be time-limited rather than egg-limited, which might favour large clutches once an appropriate oviposition site has been located. As the development of the gall and hence the fate of a clutch depends on a number of unpredictable factors, exclusive concentration of eggs in a few large clusters would involve risks which could be avoided by increasing the number of clutches. Therefore we interpret the high variation of clutch sizes in U. cardui as a mixed strategy of bet hedging and gambling.