Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Interest of a buffering system

A captcha (picture or sound) needs a lot of computing time comparing to the time usually required to generate a web page. The more captchas are hard to crack by computers, the more it takes time to create.

Conceptual solution

Pre generating captcha can prevent web site overloading. Considering the need, there is two possible solutions:

  • Captchas can be stored in volatile memory to prevent overload, but as captchas are pictures, this solution fits well for middle needs like peaks at 10 requests per second.
  • Captchas can be stored in persistent memory, like database, or simple files, and then be swap periodically to a fast volatile memory.

The JCaptcha buffering systems is an answer for both solutions.

Technical solution

A component, BufferedEngineContainer, which implements the CaptchaEngine interface, produces captchas through a normal captcha engine.

It uses two buffers; one to store captchas in a persistent way, implementation of this buffer is either a file buffer on disk, or a database. Another buffer is used to quickly deliver captchas; this is implemented with a RAM buffer, like a stack, or a list.

The BufferedEngineContainer component has two main operations:

  • Feeding of the persistent buffer.
  • Swapping from the persistent buffer to the volatile buffer.

These operations are controlled by timing components. JCaptcha provide implementations of timing components :

  • A simple one with ClockDaemon API.
  • A much richer one with the Quartz API.

At least but not last, a management component provided real time control on the Quartz implementation:

  • Defining the max size of both buffers
  • Defining the number of captchas to feed the persistent buffer
  • Defining the number of captcha to be swapped between the two buffers.
  • Defining the time of feeding operations
  • Defining the time of swapping operations
  • Defining the ratio of Localized captchas (For instance: 25% of English, 75% of French ...)
  • Stopping and starting every different operation
  • No labels