Unfortunately, this is one of those questions for which your mileage may vary greatly. Your weight, age, metabolism, activity level, liver health, all contribute to moving ceffeine through the body and can drastically affect its half-life from individual to individual.
This link goes into a great deal of detail about caffeine pharmacology and some of the factors involved.
My experience is this: I've been a HEAVY coffee drinker most of my life (think POTS per day instead of CUPS per day), though have recently switched to almost exclusively espresso. It's only been within the past year or so that I've started to find sleep issues if I ingest caffeine less than four hours before bedtime. Prior to that, I used to have a cup just before bed to relax me. Alas, no more. :)
My typical weekday routine is to have about five or six espressos in my first few hours of work. Lunch will generally include a double-shot or a large iced coffee during the summer. I generally don't have coffee in the afternoon...more because I'm not at my desk to pull a shot rather than lack of desire. I have a cup or two when I get home from work.
I find that I'm most productive in the morning, though afternoons are typically meetings, so I have a rough time gauging productivity or wakefulness in a context that is unproductive and mind-numbing. I find that wakefulness is more a function of sleep. If get my solid 6.5 hours, caffeine just helps me focus better and get more done. Bad sleep and ceffeine jsut keeps me from nodding off, with little no increase in attentiveness or productivity.
There are a lot of factors that go into your question, and it may require some experimentation to fall into your circadian rhythms, find your sweet-spot for sleep duration and caffeine intake. Studying your personal physiology and what works best for you is the ~real~ solution to this question, but I think understanding the broad strokes of caffeine pharmacology and then experimenting to see how that fits for you is an excellent first step.