Performance tuning

Splash Forums Rewrite Users Performance tuning

Tagged: ,

This topic contains 58 replies, has 4 voices, and was last updated by  RedShadow 4 years, 11 months ago.

Viewing 15 posts - 1 through 15 (of 59 total)
  • Author
    Posts
  • #18720

    pavel.arnost
    Participant

    Hi,

    I discovered that my ruleset have huge performance penalty on my JSF application. I tested simple static JSF page (/faq) with ab (apache bench) and with concurrency 30, average response time with trivial ruleset is about 200 ms and average response time with my ruleset is about 800 ms, i.e. four times higher (results are after 10k “warm-up” requests). How can I tune my ruleset to get better performance?

    Trivial and My rulesets are attached.

    Thanks,

    Regards

    Pavel

    #22947

    Hey Pavel,

    Try using the ConfigurationCacheProvider API – you will need to register this in a META-INF/services/org.ocpsoft.rewrite.config.ConfigurationCacheProvider file, but you can implement simple caching using the ServletContext.

    This will prevent the rule-set from being re-built on every request. Customize to your needs :)

    import javax.servlet.ServletContext;

    import org.ocpsoft.rewrite.servlet.config.HttpConfigurationCacheProvider;

    public class ServletContextConfigurationCacheProvider extends HttpConfigurationCacheProvider
    {
    private static final String KEY = ServletContextConfigurationCacheProvider.class.getName() + "_cachedConfig";

    @Override
    public Configuration getConfiguration(ServletContext context)
    {
    return (Configuration) context.getAttribute(KEY);
    }

    @Override
    public void setConfiguration(ServletContext context, Configuration configuration)
    {
    context.setAttribute(KEY, configuration);
    }

    @Override
    public int priority()
    {
    return 0;
    }
    }

    #22948

    pavel.arnost
    Participant

    Hi,

    thanks. I tried ServletContextConfigurationCacheProvider and it’s better, but still, with My ruleset I get average response time about 500 ms, 2.5 times more than with Trivial ruleset. Are there any other “tricks” I can try? Maybe there is some way to merge some rules into one?

    Pavel

    #22949

    Hey Pavel,

    It looks like something went wrong with your file upload – could you paste your providers in as text? Sorry for the inconvenience – I’ll try to figure out what is wrong with the file upload system.

    ~Lincoln

    #22950

    pavel.arnost
    Participant

    Here they are:

    TrivialProvider:

    public class TrivialHttpConfigurationProvider extends HttpConfigurationProvider implements NonEnriching {

    @Override
    public Configuration getConfiguration(ServletContext context) {
    HttpOperation userCheck = new HttpOperation() {
    @Override
    public void performHttp(HttpServletRewrite event, EvaluationContext context) {
    if (event instanceof HttpInboundServletRewrite) {
    HttpInboundServletRewrite rewrite = (HttpInboundServletRewrite) event;

    if (!Auth.isUserLoggedIn(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("userPreAuthUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(userLoginUrl(rewrite));
    }
    }
    }
    };

    HttpOperation userAndAcknowledgesCheck = new HttpOperation() {
    @Override
    public void performHttp(HttpServletRewrite event, EvaluationContext context) {
    if (event instanceof HttpInboundServletRewrite) {
    HttpInboundServletRewrite rewrite = (HttpInboundServletRewrite) event;

    if (!Auth.isUserLoggedIn(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("userPreAuthUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(userLoginUrl(rewrite));
    } else {
    if (!Auth.isAllAcknowledged(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("userPreAckUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(acknowledgementUrl(rewrite));
    }
    }
    }
    }
    };

    HttpOperation staffCheck = new HttpOperation() {
    @Override
    public void performHttp(HttpServletRewrite event, EvaluationContext context) {
    if (event instanceof HttpInboundServletRewrite) {
    HttpInboundServletRewrite rewrite = (HttpInboundServletRewrite) event;

    if (!Auth.isStaffLoggedIn(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("staffPreAuthUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(adminLoginUrl(rewrite));
    }
    }
    }
    };

    return ConfigurationBuilder.begin()
    .addRule(Join.path("/faq").to("/faq.html"))

    /* fallback, default deny */
    .defineRule()
    .when(Direction.isInbound()
    .and(DispatchType.isRequest())
    .andNot(Path.matches("{1}javax.faces.resource{2}").where("1").matches(".*").where("2").matches(".*"))
    .andNot(Path.matches("/css/{1}").where("1").matches(".*"))
    .andNot(Path.matches("/media/{1}").where("1").matches(".*"))
    .andNot(Path.matches("/avatar/{1}").where("1").matches(".*"))
    .andNot(Path.matches("/avatar/proposed-change/{1}").where("1").matches(".*")))
    .perform(SendStatus.SendError.code(403));
    }

    @Override
    public int priority() {
    return 10;
    }

    private String preAuthUrl(HttpInboundServletRewrite rewrite) {
    String preAuthUrl = rewrite.getRequest().getRequestURL().toString();
    String queryString = rewrite.getRequestQueryString();

    if (queryString != null && !queryString.isEmpty()) {
    preAuthUrl = preAuthUrl + "?" + queryString;
    }

    return preAuthUrl;
    }

    private String userLoginUrl(HttpInboundServletRewrite rewrite) {
    String contextPath = rewrite.getRequest().getContextPath();

    return contextPath + "/login.html";
    }

    private String adminLoginUrl(HttpInboundServletRewrite rewrite) {
    String contextPath = rewrite.getRequest().getContextPath();

    return contextPath + "/admin/login.html";
    }

    private String acknowledgementUrl(HttpInboundServletRewrite rewrite) {
    String contextPath = rewrite.getRequest().getContextPath();

    return contextPath + "/user/acknowledgement.html";
    }
    }

    MyProvider:

    public class MyHttpConfigurationProvider extends HttpConfigurationProvider implements NonEnriching {

    @Override
    public Configuration getConfiguration(ServletContext context) {
    HttpOperation userCheck = new HttpOperation() {
    @Override
    public void performHttp(HttpServletRewrite event, EvaluationContext context) {
    if (event instanceof HttpInboundServletRewrite) {
    HttpInboundServletRewrite rewrite = (HttpInboundServletRewrite) event;

    if (!Auth.isUserLoggedIn(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("userPreAuthUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(userLoginUrl(rewrite));
    }
    }
    }
    };

    HttpOperation userAndAcknowledgesCheck = new HttpOperation() {
    @Override
    public void performHttp(HttpServletRewrite event, EvaluationContext context) {
    if (event instanceof HttpInboundServletRewrite) {
    HttpInboundServletRewrite rewrite = (HttpInboundServletRewrite) event;

    if (!Auth.isUserLoggedIn(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("userPreAuthUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(userLoginUrl(rewrite));
    } else {
    if (!Auth.isAllAcknowledged(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("userPreAckUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(acknowledgementUrl(rewrite));
    }
    }
    }
    }
    };

    HttpOperation staffCheck = new HttpOperation() {
    @Override
    public void performHttp(HttpServletRewrite event, EvaluationContext context) {
    if (event instanceof HttpInboundServletRewrite) {
    HttpInboundServletRewrite rewrite = (HttpInboundServletRewrite) event;

    if (!Auth.isStaffLoggedIn(event.getRequest())) {
    rewrite.getRequest().getSession().setAttribute("staffPreAuthUrl", preAuthUrl(rewrite));
    rewrite.redirectTemporary(adminLoginUrl(rewrite));
    }
    }
    }
    };

    return ConfigurationBuilder.begin()
    /* home, login and registration */
    .addRule(Join.path("/").to("/index.html"))
    .addRule(Join.path("/prihlaseni").to("/login.html"))
    .addRule(Join.path("/prihlaseni/facebook").to("/user/facebooklogin.html"))
    .addRule(Join.path("/zapomenute-heslo").to("/user/lostpassword.html"))
    .addRule(Join.path("/obnova-hesla/{token}").to("/user/resetpassword.html"))
    .addRule(Join.path("/registrace/pracovnik/facebook").to("/user/registration/facebookworker.html"))
    .addRule(Join.path("/registrace/zadavatel/facebook").to("/user/registration/facebooksubmitter.html"))
    .addRule(Join.path("/registrace/facebook/dokonceni").to("/user/registration/facebookfinish.html"))
    .addRule(Join.path("/registrace/pracovnik").to("/user/registration/worker.html"))
    .addRule(Join.path("/registrace/zadavatel").to("/user/registration/submitter.html"))
    .addRule(Join.path("/kontrola-psc/{postCode}").to("/user/postcode/check.html"))
    .addRule(Join.path("/mapa").to("/map.html"))
    .addRule(Join.path("/odeslat-dotaz-provozovateli").to("/feedback.html"))
    .addRule(Join.path("/profil/{nickname}").to("/user/profile.html"))
    .addRule(Join.path("/faq").to("/faq.html"))

    /* dashboard and profile */
    .addRule(Join.path("/udeleni-souhlasu").to("/user/acknowledgement.html").perform(userCheck))
    .addRule(Join.path("/prehled").to("/user/dashboard.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/zmena-hesla").to("/user/passwordchange.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/zadost-o-provereni").to("/user/applyforverification.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/muj-profil").to("/user/myprofile.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/uprava-profilu").to("/user/myprofileedit.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/muj-ucet").to("/user/myaccount.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/moje-oblasti-a-kategorie").to("/user/myregionsandcategories.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/nastaveni-notifikaci").to("/user/notificationpreferences.html").perform(userAndAcknowledgesCheck))

    /* messages */
    .addRule(Join.path("/moje-zpravy").to("/user/message/list.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/zprava/link").to("/user/message/link.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/zprava/{id}").to("/user/message/detail.html").perform(userAndAcknowledgesCheck))

    /* admin */
    .addRule(Join.path("/admin/").to("/admin/index.html").perform(staffCheck))
    .addRule(Join.path("/admin/prihlaseni").to("/admin/login.html"))
    .addRule(Join.path("/admin/kategorie").to("/admin/categories.html").perform(staffCheck))
    .addRule(Join.path("/admin/pozadavaky-ke-schvaleni").to("/admin/approvalrequests.html").perform(staffCheck))
    .addRule(Join.path("/admin/uzivatele").to("/admin/user/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/zadosti-o-provereni").to("/admin/verifications.html").perform(staffCheck))
    .addRule(Join.path("/admin/ukoly").to("/admin/task/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/ukol/{id}").to("/admin/task/detail.html").where("id").matches(".*").perform(staffCheck))
    .addRule(Join.path("/admin/ukol").to("/admin/task/detail.html").perform(staffCheck))
    .addRule(Join.path("/admin/uzivatel/{id}").to("/admin/user/detail.html").where("id").matches(".*").perform(staffCheck))
    .addRule(Join.path("/admin/uzivatel").to("/admin/user/detail.html").perform(staffCheck))
    .addRule(Join.path("/admin/bankovniucty").to("/admin/bankaccounts.html").perform(staffCheck))
    .addRule(Join.path("/admin/bankovniucet").to("/admin/bankaccount.html").perform(staffCheck))
    .addRule(Join.path("/admin/bankovnitransakce").to("/admin/banktransactions.html").perform(staffCheck))
    .addRule(Join.path("/admin/platby").to("/admin/payments.html").perform(staffCheck))
    .addRule(Join.path("/admin/konfigurace").to("/admin/configuration/detail.html").perform(staffCheck))
    .addRule(Join.path("/admin/konfigurace/upravit").to("/admin/configuration/edit.html").perform(staffCheck))
    .addRule(Join.path("/admin/urovne-uzivatelu").to("/admin/userlevel/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/nastroje").to("/admin/utils/index.html").perform(staffCheck))

    /* admin: notifications */
    .addRule(Join.path("/admin/notifikace").to("/admin/notification/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/notifikace/upravit").to("/admin/notification/edit.html").perform(staffCheck))
    .addRule(Join.path("/admin/notifikace/{id}").to("/admin/notification/detail.html").perform(staffCheck))

    /* admin: acknowledgements */
    .addRule(Join.path("/admin/souhlasy").to("/admin/acknowledgement/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/souhlasy/upravit").to("/admin/acknowledgement/edit.html").perform(staffCheck))
    .addRule(Join.path("/admin/souhlasy/pridat").to("/admin/acknowledgement/add.html").perform(staffCheck))

    /* admin: greetings */
    .addRule(Join.path("/admin/pozdravy").to("/admin/greeting/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/pozdrav/upravit").to("/admin/greeting/edit.html").perform(staffCheck))
    .addRule(Join.path("/admin/pozdrav/pridat").to("/admin/greeting/add.html").perform(staffCheck))

    /* admin: staff */
    .addRule(Join.path("/admin/sprava-personalu").to("/admin/staff/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/personal/pridat").to("/admin/staff/add.html").perform(staffCheck))
    .addRule(Join.path("/admin/personal/upravit").to("/admin/staff/edit.html").where("id").matches(".*").perform(staffCheck))
    .addRule(Join.path("/admin/personal/zmena-hesla/{id}").to("/admin/staff/passwordchange.html").where("id").matches(".*").perform(staffCheck))
    .addRule(Join.path("/admin/personal/{id}").to("/admin/staff/detail.html").where("id").matches(".*").perform(staffCheck))

    /* admin: coupons */
    .addRule(Join.path("/admin/seznam-kuponu").to("/admin/coupon/list.html").perform(staffCheck))
    .addRule(Join.path("/admin/pridani-kuponu").to("/admin/coupon/add.html").perform(staffCheck))
    .addRule(Join.path("/admin/uprava-kuponu/{id}").to("/admin/coupon/edit.html").perform(staffCheck))

    /* task */
    .addRule(Join.path("/moje-ukoly").to("/task/mytasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/uhrazeni-poplatku/{id}").to("/user/payment.html").where("id").matches(".*").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/payu/ok").to("/user/payment/ok.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/payu/error").to("/user/payment/error.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/payu/update").to("/user/payment/update.html"))
    .addRule(Join.path("/hotove-ukoly").to("/task/finishedtasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/aktivni-ukoly").to("/task/activetasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/nevyhrane-ukoly").to("/task/notwontasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/ukoly-cekajici-na-schvaleni").to("/task/waitingtasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/ukoly-cekajici-na-uhrazeni").to("/task/waitingforpaymenttasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/ukoly-cekajici-na-splneni").to("/task/assignedtasks.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/upravit-ukol/{id}").to("/task/edit.html").where("id").matches(".*").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/upravit-ukol").to("/task/edit.html").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/podat-ukol").to("/task/post.html").where("id").perform(userAndAcknowledgesCheck))
    .addRule(Join.path("/{urlName}").to("/task/detail.html")
    .where("urlName").matches("\d+-[0-9a-z-]+"))
    .addRule(Join.path("/{regionName}/{categoryName}/hledani/{searchTerm}").to("/task/search.html")
    .where("regionName").matches("[a-z-]+")
    .where("categoryName").matches("[a-z-]+")
    .where("searchTerm").matches(".*"))
    .addRule(Join.path("/{regionName}/{categoryName}").to("/task/list.html")
    .where("regionName").matches("[a-z-]+")
    .where("categoryName").matches("[a-z-]+"))

    /* fallback, default deny */
    .defineRule()
    .when(Direction.isInbound()
    .and(DispatchType.isRequest())
    .andNot(Path.matches("{1}javax.faces.resource{2}").where("1").matches(".*").where("2").matches(".*"))
    .andNot(Path.matches("/css/{1}").where("1").matches(".*"))
    .andNot(Path.matches("/media/{1}").where("1").matches(".*"))
    .andNot(Path.matches("/avatar/{1}").where("1").matches(".*"))
    .andNot(Path.matches("/avatar/proposed-change/{1}").where("1").matches(".*")))
    .perform(SendStatus.SendError.code(403));
    }

    @Override
    public int priority() {
    return 10;
    }

    private String preAuthUrl(HttpInboundServletRewrite rewrite) {
    String preAuthUrl = rewrite.getRequest().getRequestURL().toString();
    String queryString = rewrite.getRequestQueryString();

    if (queryString != null && !queryString.isEmpty()) {
    preAuthUrl = preAuthUrl + "?" + queryString;
    }

    return preAuthUrl;
    }

    private String userLoginUrl(HttpInboundServletRewrite rewrite) {
    String contextPath = rewrite.getRequest().getContextPath();

    return contextPath + "/login.html";
    }

    private String adminLoginUrl(HttpInboundServletRewrite rewrite) {
    String contextPath = rewrite.getRequest().getContextPath();

    return contextPath + "/admin/login.html";
    }

    private String acknowledgementUrl(HttpInboundServletRewrite rewrite) {
    String contextPath = rewrite.getRequest().getContextPath();

    return contextPath + "/user/acknowledgement.html";
    }
    }

    #22951

    pavel.arnost
    Participant

    Oops, and btw, with ServletContextConfigurationCacheProvider I sometimes get these exceptions:

    java.lang.NullPointerException
    at java.util.LinkedList$ListItr.next(LinkedList.java:891)
    at org.ocpsoft.rewrite.bind.Bindings.enqueuePreOperationSubmissions(Bindings.java:69)
    at org.ocpsoft.rewrite.bind.Bindings.enqueueSubmission(Bindings.java:49)
    at org.ocpsoft.rewrite.servlet.config.Path.evaluateHttp(Path.java:115)
    at org.ocpsoft.rewrite.servlet.config.HttpCondition.evaluate(HttpCondition.java:41)
    at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
    at org.ocpsoft.rewrite.servlet.config.rule.Join.evaluate(Join.java:107)
    at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
    at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:101)
    at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
    at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:101)
    at org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewriteHttp(DefaultHttpRewriteProvider.java:62)
    at org.ocpsoft.rewrite.servlet.http.HttpRewriteProvider.rewrite(HttpRewriteProvider.java:44)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:221)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:177)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

    java.util.ConcurrentModificationException
    at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:953)
    at java.util.LinkedList$ListItr.next(LinkedList.java:886)
    at org.ocpsoft.rewrite.bind.Bindings.enqueuePreOperationSubmissions(Bindings.java:69)
    at org.ocpsoft.rewrite.bind.Bindings.enqueueSubmission(Bindings.java:49)
    at org.ocpsoft.rewrite.servlet.config.Path.evaluateHttp(Path.java:115)
    at org.ocpsoft.rewrite.servlet.config.HttpCondition.evaluate(HttpCondition.java:41)
    at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
    at org.ocpsoft.rewrite.servlet.config.rule.Join.evaluate(Join.java:107)
    at org.ocpsoft.rewrite.servlet.config.rule.IJoin$JoinParameter.evaluate(IJoin.java:140)
    at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
    at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:101)
    at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
    at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:101)
    at org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewriteHttp(DefaultHttpRewriteProvider.java:62)
    at org.ocpsoft.rewrite.servlet.http.HttpRewriteProvider.rewrite(HttpRewriteProvider.java:44)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:221)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:177)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1771)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

    I use version 1.1.0.Final.

    #22952

    Hey Pavel,

    I’ve been looking at your providers, and I think at this point I really need to debug and profile your application. Could you send it to me? This exception worries me.

    ~Lincoln

    #22953

    pavel.arnost
    Participant

    Hi,

    I attached simple test project. I just started it in Tomcat, tested it with:

    ab -n 1000 -c 50 -k http://localhost:8080/region-name/category-name

    and exception occured.

    Regards

    Pavel

    #22954

    Okay – I’ve gotten to take a look at this. You’ve revealed a thread safety issue in Rewrite when using a ConfigurationCacheProvider and parameter binding. We’ll have to address this in 2.0.

    #22955

    pavel.arnost
    Participant

    Hi,

    thanks.

    But even with ConfigurationCacheProvider, there is still big perfomance penalty for my ruleset. I attached trivial JSF application, with TrivialHttpConfigurationProvider and MyHttpConfigurationProvider. Test page (/works) is about 3-4 times faster with Trivial provider than with My provider.

    Btw for one test, I subclassed Join and added println to the beginning of the evaluate() method – it was called about 100 times for one page load of /works page. After I added <h:link> to index, it was called 268 times. Is this expected?

    Thanks,

    Regards

    Pavel

    #22956

    No, that’s not expected behavior unless you are building 100 joins – strange…. I will try to look at that as well…

    #22957

    pavel.arnost
    Participant

    Well, there ARE about 100 Join rules in My ruleset :-) But I would not expect that all will be evaluated – I tried perform(Lifecycle.handled()), but Joins then did not work. Most of my rules are simple, like Join.path(“/faq”).to(“/faq.html”), 100 of them should not slow application down.

    #22958

    Right, only a few should be evaluated, and even that should not really affect performance like this. I am looking :)

    #22960

    So I’ve tried to test out the performance issue, and my benchmark run with:

    ab -n 25 -c 1 -k http://127.0.0.1:8080/rewritetest/region-name/category-name

    Came back with this result (ran for 20,000 requests) – without a ConfigurationCacheProvider.

    Percentage of the requests served within a certain time (ms)
    50% 14
    66% 14
    75% 85
    80% 85
    90% 85
    95% 85
    98% 85
    99% 85
    100% 85 (longest request)

    I am not seeing the performance slowdown that you are, but I do see the concurrency issue so I’m working on that.

    #22961

    Though, I’m not really sure what is up with the ab command here because I only asked it to run for 25 requests and it just kept running until I killed it… running concurrently seems to hang the command.

Viewing 15 posts - 1 through 15 (of 59 total)

You must be logged in to reply to this topic.

Comments are closed.