Pilgrims circled the Kaaba, which is considered to be the House of God, at this year’s hajj in Mecca, Saudi Arabia. Dar Yasin/Associated Press

At least 1.7 million foreign pilgrims are in Mecca, Saudi Arabia, this week for the hajj, the annual five-day pilgrimage that Muslims from around the world make to follow in the footsteps of the Prophet Muhammad.

Amid growing demand and concerns for safety after deadly accidents, the Saudi government has been rapidly expanding Mecca’s hajj facilities to accommodate more pilgrims. At its peak in 2012, the hajj included 3.16 million pilgrims. But even at a rate of 3 million people per hajj, it would be impossible for all the world’s 1.8 billion Muslims to perform the Islamic duty of the pilgrimage in their lifetimes. In fact, for all Muslims who are alive today to perform hajj, it would take at least 581 years.

How long it would take to get every Muslim to hajj 1.8 billion If there were 3 million people per hajj, it would take 581 years. 1.5 1 .5 2018 2100 2200 2300 2400 2500 2599 How long it would take to get every Muslim to hajj 1.8 billion If there were 3 million people per hajj, it would take 581 years. 1.5 1 .5 2018 2200 2400 2599 Note: The timeline assumes a rate of 3 million people per hajj. Some years, hajj occurs twice because it follows the lunar calendar.

That’s just looking at the Muslims alive today — not accounting for future birth rates or for people who have already performed hajj, though a 2013 Pew survey of 39 countries found that 9 percent of Muslims had.

All Muslims who are physically and financially able to complete the hajj are supposed to do so at least once in their lives. Attendance by foreign pilgrims has grown more than tenfold since World War II. (In 2013, attendance quotas dropped to account for continuing construction in Mecca.)

2012 3.16 million Pilgrims at the hajj, in millions 2018 estimated 2.28 million 1997 1.94 million total Domestic pilgrims Foreign pilgrims ’96 ’00 ’05 ’10 ’15 2012 3.16 million Pilgrims at the hajj, in millions 2018 estimated 2.28 million 1997 1.94 million total Domestic pilgrims Foreign pilgrims ’96 ’00 ’05 ’10 ’15 Source: Kingdom of Saudi Arabia General Authority for Statistics | Note: Hajj occurred twice in 2006.

Not everyone who wants to make the hajj can do so easily, and millions of Muslims all over the world wait years for the chance. The costs can be prohibitive — two to three times a year’s salary in some places — and visas can be hard to get.

At least a quarter of pilgrims every year are citizens or residents of Saudi Arabia. The Saudi government sets quotas for every other country that sends pilgrims to the hajj based on its Muslim population.

Even countries with large Muslim populations can send only a small fraction of their citizens to the hajj. In Indonesia — which at more than 200 million has by far the largest Muslim population in the world — the wait time can range from seven to 37 years. Some countries complain that the quota allocation is not transparent enough, or that it should be based on demand rather than on Muslim population.

Other critics say Mecca is already at capacity during the hajj, and expansion efforts have come at the cost of Islam’s cultural heritage and the spirituality of the pilgrimage. Several historic Islamic sites were destroyed in recent years to make way for luxury high-rise hotels and malls that cater only to wealthy pilgrims. These developments dominate the Kaaba, the cubelike structure at the center of the Grand Mosque that is circled by pilgrims and that is considered to be the House of God.