#build time

1 messages · Page 1 of 1 (latest)

hazy abyss
#

im usinf static exports and i have approximately 10000 pages in app router, im not gonna use ISR. but it uses a lot of vercel usage and very long build time. how can i make it build extremely faster?

forest forgeBOT
#

Hi @hazy abyss. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the knowledge sources, I can offer some suggestions to help reduce your build time for a large Next.js application with static exports. However, it's important to note that with 10,000 pages, you may still face challenges in achieving extremely fast build times. Here are some strategies you can consider:

  1. Use Incremental Static Regeneration (ISR): Although you mentioned you're not going to use ISR, it's worth reconsidering as it's specifically designed to handle large numbers of static pages efficiently. ISR allows you to generate a subset of pages at build time and the rest on-demand, significantly reducing build times. Learn more about ISR (https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration)

  2. Optimize your code and dependencies:

  3. Manage and optimize build cache: Understand and properly manage the build cache to speed up the build process. Understanding build cache (https://vercel.com/docs/deployments/troubleshoot-a-build#understanding-build-cache)

#
  1. Consider using fallback pages: If possible, implement fallback pages to generate a subset of pages at build time and the rest on-demand. This can significantly reduce initial build times. Fallback pages (https://vercel.com/guides/what-can-i-do-when-i-run-into-build-output-limits-with-next-js-on-vercel#fallback-pages)

  2. Optimize your data fetching: If you're fetching data for your static pages, ensure you're doing so efficiently. Consider batching requests or using a more performant data source.

  3. Review and optimize your next.config.js: Ensure your configuration isn't causing unnecessary slowdowns.

  4. Use modularized imports: If you're using libraries with many exports (like react-icons or Material UI icons), use modularized imports to reduce compilation time. Example of modularized imports (https://github.com/vercel/next.js/issues/45529#issuecomment-1531912811)

  5. Monitor and analyze your build process: Use the NEXT_CPU_PROF=1 and NEXT_TURBOPACK_TRACING=1 environment variables to generate traces that can help identify bottlenecks in your build process. How to generate traces (https://github.com/vercel/next.js/issues/48748#issuecomment-1578374105)

Remember, with 10,000 pages, you're likely to hit some platform limits. Vercel recommends using ISR for applications with thousands of pages or more to keep build times low. If you absolutely can't use ISR, you might need to consider splitting your application into smaller parts or exploring other optimization techniques specific to your use case.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@hazy abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

hazy abyss
#

what usage will increase on vercel if i switch to isr?
and what are the limits of them at vercel

#

@forest forge what usage will increase on vercel if i switch to isr?
and what are the limits of them at vercel

forest forgeBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

Based on the knowledge sources provided, I can answer your question about the usage increase and limits when switching to Incremental Static Regeneration (ISR) on Vercel.

When you switch to ISR, you'll primarily see an increase in two types of usage:

  1. ISR Reads: These are the total amount of Read Units used to access ISR data.
  2. ISR Writes: These are the total amount of Write Units used to store new ISR data.

Both ISR Reads and Writes are measured in 8 KB units Vercel ISR Pricing (https://vercel.com/docs/pricing/incremental-static-regeneration#manage-and-optimize-usage-for-incremental-static-regeneration).

As for the limits on Vercel, they vary depending on your plan:

For the Hobby plan:

  • ISR Reads: First 1,000,000 included
  • ISR Writes: First 200,000 included

For the Pro plan:

  • ISR Reads: First 10,000,000 included
  • ISR Writes: First 2,000,000 included

Vercel Hobby Plan Limits (https://vercel.com/docs/accounts/plans/hobby#managed-infrastructure-features)

If you exceed these limits on the Pro plan, additional usage is charged at regional rates. The exact pricing can vary by region, so you'd need to check the specific regional pricing for your deployment location.

It's worth noting that while ISR usage will increase, it can significantly reduce your build times and improve performance, especially for large sites. ISR allows you to generate pages on demand and update them periodically, which can be more efficient than rebuilding all pages on every deployment Vercel ISR Overview (https://vercel.com/docs/incremental-static-regeneration#incremental-static-regeneration-isr).

#

Additionally, there's no limit on storage for ISR. All the data you write remains cached for the duration you specify, unless it goes unaccessed for 31 days ISR Storage Limits (https://vercel.com/docs/incremental-static-regeneration/limits-and-pricing#incremental-static-regeneration-usage-and-pricing).

Remember, while ISR usage will increase, it may decrease usage in other areas, such as Function Invocations and Duration, as fewer pages need to be generated at build time.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@hazy abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

hazy abyss
#

i have 10000 pages, will i exceeds the limit

#

@forest forge ive 10000 pages, will i exceeds the limit

forest forgeBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

Based on the information provided in the knowledge sources, I can't definitively say whether you will exceed the ISR limits with 10,000 pages, as it depends on various factors such as the size of your pages, frequency of updates, and your Vercel plan. However, I can provide some insights to help you understand the potential usage:

  1. ISR Reads: On the Hobby plan, you get 1,000,000 Read Units included, while on the Pro plan, you get 10,000,000 Read Units Vercel Hobby Plan Limits (https://vercel.com/docs/accounts/plans/hobby#managed-infrastructure-features). Each Read Unit is 8 KB of data read from the ISR cache.

  2. ISR Writes: The Hobby plan includes 200,000 Write Units, and the Pro plan includes 2,000,000 Write Units Vercel Hobby Plan Limits (https://vercel.com/docs/accounts/plans/hobby#managed-infrastructure-features). Each Write Unit is 8 KB of data written to the ISR cache.

With 10,000 pages, you might be approaching or exceeding these limits, especially on the Hobby plan. However, it's important to note that ISR is designed to handle large numbers of pages efficiently. The actual usage will depend on:

  • How often your pages are accessed (affecting Read Units)
  • How frequently your pages are updated (affecting Write Units)
  • The size of your pages (larger pages will use more units)

If you're concerned about exceeding limits, consider the following:

  1. Monitor your usage: Vercel provides usage metrics in the dashboard, allowing you to track your ISR Reads and Writes Vercel ISR Usage (https://vercel.com/docs/pricing/manage-and-optimize-usage#incremental-static-regeneration-isr).
#
  1. Optimize your revalidation strategy: Use longer revalidation intervals for content that changes less frequently, and implement on-demand revalidation for content that needs immediate updates Vercel ISR Optimization (https://vercel.com/docs/pricing/incremental-static-regeneration#optimizing-isr-reads-and-writes).

  2. Consider upgrading to the Pro plan if you're on Hobby, as it provides significantly higher limits.

  3. If you do exceed the included limits on the Pro plan, you'll be charged for additional usage based on regional pricing Vercel Pro Plan Regional Pricing (https://vercel.com/docs/accounts/plans/pro#regional-pricing).

Remember, while 10,000 pages is a large number, ISR is specifically designed to handle such scale efficiently. It's recommended to implement ISR and monitor your usage, adjusting your strategy as needed based on the actual metrics.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@hazy abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

hazy abyss
#

@forest forge
pages are cached by cloudflare
updated every day
pages size 1-2mb
now gimme approx number of usage ill use

forest forgeBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

Based on the information you've provided and the knowledge sources available, I can give you an approximate estimate of the ISR usage you might expect on Vercel. However, please note that this is a rough calculation and actual usage may vary.

Given:

  • 10,000 pages
  • Pages are cached by Cloudflare
  • Updated every day
  • Page size: 1-2 MB

Let's calculate:

  1. ISR Writes:

  2. ISR Reads:

    • Since pages are cached by Cloudflare, ISR reads on Vercel might be significantly reduced.
    • However, let's assume each page is read at least once from Vercel's ISR cache daily.
    • Read Units per page: 1,536 KB / 8 KB = 192 Read Units
    • Daily Read Units: 10,000 * 192 = 1,920,000 Read Units per day

Approximate monthly usage:

  • ISR Writes: 1,920,000 * 30 = 57,600,000 Write Units per month
  • ISR Reads: 1,920,000 * 30 = 57,600,000 Read Units per month

These numbers significantly exceed the included limits for both Hobby and Pro plans Vercel Hobby Plan Limits (https://vercel.com/docs/accounts/plans/hobby#managed-infrastructure-features).

On the Pro plan, you would be using:

  • About 47,600,000 additional Write Units per month
  • About 47,600,000 additional Read Units per month

The exact cost would depend on your region, but you can expect significant additional charges for this usage Vercel Pro Plan Regional Pricing (https://vercel.com/docs/accounts/plans/pro#regional-pricing).

#

Please note that this is a high-end estimate. Your actual usage could be lower, especially if:

  1. Cloudflare caching is very effective, reducing reads from Vercel's ISR cache.
  2. Not all pages need daily updates.
  3. You implement strategies to optimize your ISR usage, such as longer revalidation intervals for less frequently changing content Vercel ISR Optimization (https://vercel.com/docs/pricing/incremental-static-regeneration#optimizing-isr-reads-and-writes).

Given this high usage, you might want to consider alternative strategies or consult with Vercel about enterprise-level solutions that can handle this scale more cost-effectively.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@hazy abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

hazy abyss
#

@forest forge damn it i have to quit vercel

forest forgeBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

I understand your frustration with the potential costs and limitations you might face on Vercel given your specific use case. While Vercel offers powerful features like ISR, it's true that for very large sites with frequent updates, the costs can become significant.

However, before making a final decision to quit Vercel, you might want to consider a few alternatives:

  1. Self-hosting (https://nextjs.org/docs/app/building-your-application/deploying#self-hosting): Next.js can be self-hosted on any platform that supports Node.js. This would give you more control over your infrastructure and potentially reduce costs.

  2. Static HTML Export (https://nextjs.org/docs/app/building-your-application/deploying#static-html-export): If your site doesn't require server-side features, you could use Next.js static export and host the resulting files on a static hosting service, which could be more cost-effective.

  3. Optimize your ISR strategy (https://vercel.com/docs/pricing/incremental-static-regeneration#optimizing-isr-reads-and-writes): If you decide to stay with Vercel, you could try to optimize your ISR usage by implementing longer revalidation intervals for less frequently changing content and using on-demand revalidation for critical updates.

  4. Contact Vercel: For large-scale applications, Vercel offers enterprise plans that might be more suitable for your needs. It could be worth discussing your specific use case with their sales team.

If you do decide to move away from Vercel, make sure to carefully plan your migration to ensure a smooth transition. Consider factors like build processes, deployment strategies, and how you'll handle features you're currently using on Vercel.

#

Remember, each hosting solution has its own trade-offs in terms of features, performance, and cost. The best choice depends on your specific requirements and constraints.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@hazy abyss Kapa.ai is still learning and improving, please let me know how I did by reacting below.

hazy abyss
#

@forest forge is it possible to one click revalidate cache all pages on cloudflare

forest forgeBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

I apologize, but I'm specifically tuned to answer questions about NextJS. Your question is about Cloudflare's caching system, which is a different technology.

However, I can provide some information about revalidating cache in NextJS, which might be relevant if you're using NextJS with Cloudflare:

In NextJS, you can use the revalidatePath function to revalidate the cache for all pages at once. Here's how you can do it:

import { revalidatePath } from 'next/cache'

revalidatePath('/', 'layout')

This will revalidate all pages in your NextJS application NextJS revalidatePath API (https://nextjs.org/docs/app/api-reference/functions/revalidatePath#revalidating-all-data).

However, it's important to note that this only affects the NextJS cache, not Cloudflare's cache. If you're using Cloudflare in front of your NextJS application, you would need to handle Cloudflare's cache separately.

If you need specific information about revalidating Cloudflare's cache, I recommend checking Cloudflare's documentation or asking a question specifically about Cloudflare caching.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: