If neither your space nor your budget is constrained, then go for the 27 inch.
I think if you are optimising for productivity you would want the 27", certainly from my experience.
My own opinion, for what it is worth: if you lack focus I think you are better off trying to build good habits or to work on things that interest you.
You can just as easily switch to reading HN or reddit on a smaller screen as you can a larger. You can just as easily go fullscreen on a larger display to block out distractions, but you also have more space so you can, if working on UI for example, have the UI in one half and an editor/IDE in the other, which can speed you up.
If it is difficult to make yourself do work, you can try to build good habits using apps like Focus to remind you if you tend to go off on reading sprees when working. Good luck!