Motivation

The simplified working mechanism of the currently implemented HistoryServer is as follows: it periodically retrieves archive files from HDFS and downloads them to local storage.


// Issue 1

for (FileStatus archive : archives) {

  // Issue 2,processArchive

  for (ArchivedJson archive :                

      FsJsonArchivist.readArchivedJsons(jobArchive) {

    writeTargetFile();

  }

}

updateOverview();


In our production environment, the following issues exist:

Issue 1: When the HistoryServer starts up, jobs appearing later in the sequence (i.e., those that finished earlier) must wait sequentially for the preceding jobs to complete their downloads before they can be processed and become visible to users. If the number of jobs is excessive, the startup process becomes extremely time-consuming.

Issue 2: When an individual job is excessively large—for instance, due to a complex topology or multiple failovers resulting in an excessive volume of archived details—users must wait for all files associated with that specific job to finish downloading before the job becomes visible to them.

In actual usage, suppose the HistoryServer's Overview page displays n jobs, we may only be interested in the archived details for one specific task, rather than the archived details for all tasks.


So I want to propose introducing a lazy loading mode to load archive details on demand, while keeping the original loading mode unchanged.

  • On-demand loading: download is triggered only when the user accesses the data
  • Asynchronous loading:
  • Overview information is small → load synchronously
  • Detail information is large → load asynchronously
  • Benefit: Improve HistoryServer loading speed to enhance user experience.

Briefly tested the visibility of job information on the overview page(The overview page will be refreshed manually).

Case

EAGER

LAZY

Finish a wordcount job

(parallelism = 1)

< 1s ~ ${refresh-interval}

< 1s

Finish a complicated SQL job

(parallelism = 512)

≈ 27s

< 1s

HistoryServer Startup

(about 20 completed jobs)

≈ 40s

≈ 1s

Delete archive

${refresh-interval}

${refresh-interval}





Public Interfaces

N/A



Proposed Changes

Summary

HistoryServerArchiveFetcher.ArchiveEventType

└── Extended States: PENDING -> OVERVIEW_PARSING -> OVERVIEW_CREATED -> DETAIL_PARSING -> CREATED

HistoryServerArchiveFetcher#lazyProcessArchive

└── Supports segmented downloading of overview and detail information.

1. Configuration


Key

Default

Type

Description

historyserver.archive.load.mode

EAGER

String

Define the archive load mode:

  • EAGER: the default mode, periodically load all archive files
  • LAZY: load archive files on demand

historyserver.lazy.fetch.executor.common.pool-size

4

Integer

Configures the size of the shared thread pool in LAZY mode, defaults to 4.

historyserver.lazy.fetch.executor.individual.pool-size

4

Integer

Configures the size of the individual thread pool in LAZY mode, defaults to 4.

2. ArchiveEventType

  • PENDING: Archive file not yet processed, awaiting processing.
  • OVERVIEW_PARSING: Parsing overview information.
  • OVERVIEW_CREATED: Overview information parsing complete; the job in the overview page is now visible.
  • DETAIL_PARSING: Parsing detail files.
  • CREATED (Original Type): All files successfully parsed.
  • DELETED (Original Type): Local files have been cleaned up.

3. Fetcher Behavior

EAGER (default):

  • Periodically fetch archives
  • Fully synchronous processing

LAZY:

  • Added the lazyProcessArchive(String archiveId, Path archivePath, Path refreshDir) method, enabling the proactive retrieval of archive files for a specified job using a lazy-loading approach.
    • Load overview synchronously
    • Load details asynchronously
  • Introduce two thread pools:
    • commonFetchExecutor is responsible for batch job loading tasks
    • individualFetchExecutor(higher priority) handles the loading of individual jobs
  • Cleanup Logic: Periodically purges expired files based on the defined cleanup policy.
  • State Management: Manages the loading status (ArchiveEventType) of each job via the ArchiveMetaInfoCache to maintain the state transition flow.

The entire process is as follows:

The process when HistoryServer starts up is as follows:

The process when user access is as follows:

4. Request Handling

Standardizes the request processing workflow into two steps: loadResource and respondWithResource.

  • Static Files(such index.html, xx.js …): Accessed directly by the ClassLoader.
  • Archive Files: Files are read directly in EAGER(default) mode. And the LAZY mode has different process logic as below.

Overview request:

  • Load overview synchronously
  • Return immediately
  • Load details in background

Detail request:

  • If the resource is downloaded → return
  • If the resource is loading → wait
  • If the resource hasn’t been in the processing stage → trigger high-priority load and wait

5. Application Mode

  • Treat application-summary as overview, ensure the application page can see all  the jobs in this application
  • Job details reuse existing job logic



Compatibility, Deprecation, and Migration Plan

The default mode remains EAGER, ensuring backward compatibility.

The new LAZY mode will be validated for 1–2 releases. If stable, they may become the default.

Test Plan

  • Add unit tests for new functionality
  • Perform end-to-end testing with a local HistoryServer deployment

Rejected Alternatives

N/A