Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 206863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:41:03+00:00 2026-05-11T17:41:03+00:00

I’m considering developing an app for Google App Engine, which should not get too

  • 0

I’m considering developing an app for Google App Engine, which should not get too much traffic. I’d really rather not pay to exceed the free quotas. However, it seems like it would be quite easy to cause a denial of service attack by overloading the app and exceeding the quotas. Are there any methods to prevent or make it harder to exceed the free quotas? I know I could, for example, limit the number of requests from an IP (making it harder to exceed the CPU quota), but is there any way to make it harder to exceed the requests or bandwidth quotas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:41:04+00:00Added an answer on May 11, 2026 at 5:41 pm

    There are no built-in tools to prevent DoS. If you are writing Google Apps using java then you can use the service.FloodFilter filter. The following piece of code will execute before any of your Servlets do.

    package service;
    
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Map;
    
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    
    
    /**
     * 
     * This filter can protect web server from simple DoS attacks
     * via request flooding.
     * 
     * It can limit a number of simultaneously processing requests
     * from one ip and requests to one page.
     *
     * To use filter add this lines to your web.xml file in a <web-app> section.
     * 
        <filter>
            <filter-name>FloodFilter</filter-name>
            <filter-class>service.FloodFilter</filter-class>
            <init-param>
                <param-name>maxPageRequests</param-name>
                <param-value>50</param-value>
            </init-param>
            <init-param>
                <param-name>maxClientRequests</param-name>
                <param-value>5</param-value>
            </init-param>
            <init-param>
                <param-name>busyPage</param-name>
                <param-value>/busy.html</param-value>
            </init-param>
        </filter>
    
        <filter-mapping>
            <filter-name>JSP flood filter</filter-name>
            <url-pattern>*.jsp</url-pattern>
        </filter-mapping>
     *  
     *  PARAMETERS
     *  
     *  maxPageRequests:    limits simultaneous requests to every page
     *  maxClientRequests:  limits simultaneous requests from one client (ip)
     *  busyPage:           busy page to send to client if the limit is exceeded
     *                      this page MUST NOT be intercepted by this filter
     *  
     */
    public class FloodFilter implements Filter
    {
        private Map <String, Integer> pageRequests;
        private Map <String, Integer> clientRequests;
    
        private ServletContext context;
        private int maxPageRequests = 50;
        private int maxClientRequests = 10;
        private String busyPage = "/busy.html";
    
    
        public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ) throws IOException, ServletException
        {
            String page = null;
            String ip = null;
    
            try {
                if ( request instanceof HttpServletRequest ) {
                    // obtaining client ip and page URI without parameters & jsessionid
                    HttpServletRequest req = (HttpServletRequest) request;
                    page = req.getRequestURI();
    
                    if ( page.indexOf( ';' ) >= 0 )
                        page = page.substring( 0, page.indexOf( ';' ) );
    
                    ip = req.getRemoteAddr();
    
                    // trying & registering request
                    if ( !tryRequest( page, ip ) ) {
                        // too many requests in process (from one client or for this page) 
                        context.log( "Flood denied from "+ip+" on page "+page );
                        page = null;
                        // forwarding to busy page
                        context.getRequestDispatcher( busyPage ).forward( request, response );
                        return;
                    }
                }
    
                // requesting next filter or servlet
                chain.doFilter( request, response );
            } finally {
                if ( page != null )
                    // unregistering the request
                    releaseRequest( page, ip );
            }
        }
    
    
        private synchronized boolean tryRequest( String page, String ip )
        {
            // checking page requests
            Integer pNum = pageRequests.get( page );
    
            if ( pNum == null )
                pNum = 1;
            else {
                if ( pNum > maxPageRequests )
                    return false;
    
                pNum = pNum + 1;
            }
    
            // checking client requests
            Integer cNum = clientRequests.get( ip );
    
            if ( cNum == null )
                cNum = 1;
            else {
                if ( cNum > maxClientRequests )
                    return false;
    
                cNum = cNum + 1;
            }
    
            pageRequests.put( page, pNum );
            clientRequests.put( ip, cNum );
    
            return true;
        }
    
    
        private synchronized void releaseRequest( String page, String ip )
        {
            // removing page request
            Integer pNum = pageRequests.get( page );
    
            if ( pNum == null ) return;
    
            if ( pNum <= 1 )
                pageRequests.remove( page );
            else
                pageRequests.put( page, pNum-1 );
    
            // removing client request
            Integer cNum = clientRequests.get( ip );
    
            if ( cNum == null ) return;
    
            if ( cNum <= 1 )
                clientRequests.remove( ip );
            else
                clientRequests.put( ip, cNum-1 );
        }
    
    
        public synchronized void init( FilterConfig config ) throws ServletException
        {
            // configuring filter
            this.context = config.getServletContext();
            pageRequests = new HashMap <String,Integer> ();
            clientRequests = new HashMap <String,Integer> ();
            String s = config.getInitParameter( "maxPageRequests" );
    
            if ( s != null ) 
                maxPageRequests = Integer.parseInt( s );
    
            s = config.getInitParameter( "maxClientRequests" );
    
            if ( s != null ) 
                maxClientRequests = Integer.parseInt( s );
    
            s = config.getInitParameter( "busyPage" );
    
            if ( s != null ) 
                busyPage = s;
        }
    
    
        public synchronized void destroy()
        {
            pageRequests.clear();
            clientRequests.clear();
        }
    }
    
    • From: http://forums.sun.com/thread.jspa?threadID=5125779&tstart=13545

    If you are using python, then you may have to roll your own filter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Rather than two vectors (one for names, and one for… May 12, 2026 at 12:42 am
  • Editorial Team
    Editorial Team added an answer I've always been partial to YourKit. There are lots of… May 12, 2026 at 12:42 am
  • Editorial Team
    Editorial Team added an answer What you want to do is put the console into… May 12, 2026 at 12:42 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.