We often hear that we should all be getting eight hours' sleep a night. Organisations from the NHS to the US National Sleep Foundation recommend it. But where does this advice come from?
Studies carried out around the world, looking at how often diseases occur in different groups of people across a population, have come to the same conclusion: both short sleepers and long sleepers are more likely to have a range of diseases, and to live shorter lives.
But it's hard to tell whether it is short sleep that is causing disease or whether it is a symptom of a less healthy lifestyle.
Short sleepers are generally defined as those who regularly get less than six hours' sleep and long sleepers generally more than nine or 10 hours' a night.
Pre-puberty, children are recommended to get as much as 11 hours' sleep a night, however, and up to 18 hours a day for newborn babies. Teenagers should sleep for up to 10 hours a night.
Shane O'Mara, professor of experimental brain research at Trinity College Dublin, says that, while it's difficult to tell whether poor sleep is a cause or a symptom of poor health, these relationships feed off each other.
For example, people who are less fit exercise less, which leads people to sleep badly, become exhausted and less likely to exercise, and so on.
We do know that chronic sleep deprivation - that is, under-sleeping by an hour or two a night over a period of time - has been linked time and again by scientists to poor health outcomes: you don't have to go for days without sleep to suffer these negative effects.
Poor sleep has been linked to a whole range of disorders.
A review of 153 studies with a total of more than five million participants found short sleep was significantly associated with diabetes, high blood pressure, cardiovascular disease, coronary heart disease and obesity.
Studies have shown that depriving people of enough sleep for only a few nights in a row can be enough to put healthy adults into a pre-diabetic state. These moderate levels of sleep deprivation damaged their bodies' ability to control blood glucose levels.
Vaccines are less effective when we are sleep deprived, and sleep deprivation suppresses our immune system making us more prone to infection.
One study found participants who had fewer than seven hours of sleep were almost three times more likely to develop a cold than those who slept for seven hours or more.
People who don't sleep enough also appear to produce too much of the hormone ghrelin, associated with feeling hungry, and not enough of the hormone leptin, associated with feeling full, which may contribute to their risk of obesity.
There are also links to brain function and even in the long term to dementia.
Prof O'Mara explains that toxic debris builds up in your brain during the course of the day and waste is drained from the body during sleep. If you don't sleep enough, you end up in a mildly concussed state, he says.
The impact of sleeping too much is less understood, but we do know it is linked to poorer health including a higher risk of cognitive decline in older adults.
After we fall asleep we go through cycles of "sleep stages", each cycle lasting between 60 and 100 minutes. Each stage plays a different role in the many processes that happen in our body during sleep.
The first stage in each cycle is a drowsy, relaxed state between being awake and sleeping - breathing slows, muscles relax, the heart rate drops.
The second stage is a slightly deeper sleep - you may feel awake and this means that, on many nights, you may be asleep and not know it.
Stage three is deep sleep. It is very hard to wake up during this period because it is when there is the lowest amount of activity in your body.
Stages two and three together are known as slow wave sleep which is usually dreamless.
After deep sleep we go back to stage two for a few minutes, and then enter dream sleep, also called REM (rapid eye movement). As the name suggests, this is when dreaming happens.
In a full sleep cycle a person goes through all the stages of sleep from one to three, then back down to two briefly, before entering REM sleep.
Later cycles have longer periods of REM, so cutting sleep short has a disproportionately large effect on REM.
Shift work has been associated with a host of health problems. Researchers have found shift workers who get too little sleep at the wrong time of day may be increasing their risk of diabetes and obesity.
Shift workers are significantly more likely to report "fair or bad" general health according to a 2013 NHS study, which also found people in this group were a lot more likely to have a "limiting longstanding illness" than those who don't work shifts.
People who work shifts are significantly more likely to take time off sick, according to figures from the Office for National Statistics.
There is a far bigger gap for non-manual workers than manual workers - lack of sleep seems to have a bigger impact on those doing more sedentary jobs.
To judge from media reports, you'd think we were in the grip of a sleeplessness epidemic. But are we really all more sleep deprived than before?
A big piece of research looking at data from 15 countries found a very mixed picture. Six showed decreased sleep duration, seven increased sleep duration and two countries had mixed results.
Lots of a evidence suggests the amount we sleep hasn't changed that much in recent generations.But if you ask people how sleep deprived they think they are, a different picture emerges.
So why do so many people report feeling tired?
It may be that this problem is concentrated in certain groups, making the trend harder to pick up on a population-wide level.
Sleep problems vary considerably by age and gender, according to one study of 2,000 British adults. It found women at almost every age have more difficulty getting enough sleep than men.
The sexes are more or less level at adolescence but women begin to feel significantly more sleep deprived than men during the years where they may have young children, while work may become more demanding. The gap then shrinks again later in life.
Caffeine and alcohol both affect sleep duration and quality.
And later nights and more social activities mean some of us are getting less rest, despite having the same number of hours of sleep, according to Prof Derk-Jan Dijk, of the University of Surrey's sleep research centre.
Some people may also sleep too little during the week and catch up at the weekend, bringing the average up but leaving those people feeling sleep deprived.
Adolescents are particularly at risk of becoming sleep deprived, according to Prof Dijk.
Aside from a few outliers - Margaret Thatcher could apparently get by on only four hours a night - people tend to go to bed in the late evening for around seven or eight hours.
But this wasn't necessarily always the norm according to Roger Ekirch, a history professor at Virginia Tech in the USA. He published a paper in 2001 drawn from 16 years of research.
His subsequent book, At Day's Close, contained a wealth of historical evidence suggesting that hundreds of years ago, humans in many parts of the world slept in two distinct chunks.
Dr Ekirch uncovered more than 2,000 pieces of evidence in diaries, court records and literature which suggest people used to have a first sleep beginning shortly after dusk, followed by a waking period of a couple of hours, then a second sleep.
He thinks this means the body has a natural preference for segmented sleep.
Not all scientists agree. Other researchers have found hunter-gatherer communities in the modern world who sleep in one block despite not having electric lighting. This suggests sleeping in two blocks is not necessarily our default.
According to Dr Ekirch the shift from biphasal to monophasal sleep happened in the 19th Century because domestic lighting pushed bedtimes later with no corresponding change in rising time, improved lighting changed the human body clock, and the industrial revolution put a greater emphasis on productivity and efficiency.
Sleep experts say teenagers need up to 10 hours sleep a night, but almost half don't get this much according to the NHS.
Bedrooms are supposed to be a place of rest but are increasingly filled with distractions like laptops and mobile phones, making it harder for young people to nod off.
We have more different types of entertainment on offer than ever, making the temptation to stay awake greater. The blue light emitted by electronic devices makes us feel less sleepy. And the activity itself - be it talking to friends or watching TV - stimulates our brain when it should be winding down.
Digital Awareness UK and the Headmasters and Headmistresses Conference recommend a nightly "digital detox", putting mobile devices away for 90 minutes before lights out.
Last year the two organisations commissioned a poll which found a high proportion of young people check their phones after going to bed.
More people are turning up at their doctors complaining of problems sleeping.
Analysing data collected by NHS England, the BBC found in June that the number of sleeping disorder tests had increased every year over the past decade.
There are a number of factors, but the biggest is probably the rise in obesity, according to Dr Guy Leschziner, a consultant neurologist at Guy's and St Thomas' Hospital's Sleep Disorders Centre.
The most common and fastest-growing complaint he sees is obstructive sleep apnoea - where the airway collapses and people stop breathing in their sleep - and this is strongly related to weight.
The media has also played a role because people are more likely to go to their GPs having read an article or searched for their symptoms online, he says.
The recommended treatment for insomnia is cognitive behavioural therapy, and doctors are increasingly aware that they shouldn't be prescribing sleeping pills. But many still do because it's difficult to access non-drug based treatments, particularly outside big cities.
One study looked at sleep habits in 20 industrialised countries.
It found variations of up to an hour in the time people went to bed and woke up, but overall sleep duration was fairly constant across countries. Generally, if a population on average went to bed later, they woke up later too, although not in every case.
Researchers have concluded that social influences - hours worked, timing of school, leisure habits - play a far bigger role than the natural cycle of light and dark.
In Norway, where the period of lightness each day varies through the year from zero to 24 hours, sleep duration throughout the year only varies on average by about half an hour.
Both in countries like the UK, where dusk and dawn times vary considerably across the seasons, and in countries closer to the Equator where dusk and dawn times vary minimally, sleep duration remains constant through the year.
But what about the impact of artificial light?
A study of three communities who had no access to electricity, in Tanzania, Namibia and Bolivia, found the average sleep duration was 7.7 hours - in step with industrialised countries.
So sleep duration seems remarkably consistent throughout the world - it's the time we all go to bed and wake up that varies slightly.
These pre-industrialised communities did not fall asleep as soon as it got dark, but around three hours after sunset and generally woke before sunrise.
Most studies in this area suggest that artificial light delays sleep time but does not necessarily decrease overall sleep duration.
There have always been morning people and evening people. We even have genetic evidence that backs this up.
But the introduction of artificial light appears to have exacerbated this effect, particularly for people who prefer to stay up late.
If you are already inclined towards being a night owl, artificial light will make you stay up even later.
About 30% of us tend towards being morning people and 30% towards being evening people, with the other 40% of us somewhere in the middle - although marginally more people prefer early rising to late nights.
We do have some control over our body clocks, however. Those who are naturally late to bed and late to rise can try reducing their exposure to light in the evenings and making sure they get more light exposure in the daytime.
A team of researchers took a group of volunteers camping in Colorado, where they had no access to artificial light. Only 48 hours was enough to shift the campers' body clocks forward by almost two hours.
Levels of melatonin, the hormone that tells our body to prepare for sleep, began rising earlier in the volunteers - their bodies were preparing for sleep much closer to sunset.