I have the following maximization problem. Let $f(p)$ be a real function on the primes, having values in $(0,1)$. Assume that $Y$ is a given (large) positive number, and that we have the bound $$ \prod_p \left(1-f(p)\right)^{-1} \leq Y. $$ Then
$$\prod_p \left(1-f(p)\right)^{-1} \leq Y.$$
Then what is the maximal possible value of $$ \prod_p \left(1 - f(p) p^{-1} \right)^{-1}? $$ It
$$\prod_p \left(1 - f(p) p^{-1} \right)^{-1}?$$
It seems that one should choose $f$ such that it has values close to 1 for small primes, and then decrease to 0 as $p$ increases. For example, take $X = (\log Y)(\log \log Y)$ and $f(p) = (1 - p/X)$ for $p \leq X$, and $f(p)=0$ otherwise; this does quite well. Still, I cannot find the optimal function. Is there a systematic approach?