Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very slow system when having thousands of sites registered #495

Closed
anonymous-matomo-user opened this issue Jan 12, 2009 · 7 comments
Closed
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

When trying to log in as superuser and having thousands of websites listed. the system is tremendously slow. the reason seems to be line 82 in /core/View.php

the function usort is being used and the sort is very slow causing the many timeouts.

Maybe sort in db? or in other efficient way?

@robocoder
Copy link
Contributor

Scaleability is on the TODO list (e.g., tickets #386 and #409).

Assuming your profiling has pinpointed it to this line, try replacing it with:

usort($sites, create_function(‘$site1, $site2’, ‘return strcasecmp($site1[$site2[“name”](“name”],));’));

@robocoder
Copy link
Contributor

Let’s try that again in a code block:

```
usort($sites, create_function(‘$site1, $site2’, ‘return strcasecmp($site1[“name”], $site2[“name”]);’));
```

@robocoder
Copy link
Contributor

I don’t think that line of code is the bottleneck.

I just ran a simulation using 23,000+ domain names. Before my optimization: 2.83 seconds; After: 1.89 seconds.

@robocoder
Copy link
Contributor

What server side errors are you seeing?

@anonymous-matomo-user
Copy link
Author

I get this message: Allowed memory size of X bytes exhausted (tried to allocate Y bytes )…

the only thing that helped me “solve” the problem is to give up the sorting.
We have over 80K sites listed and growing. and it is impossible to sort them this way.

After all the sorting is for the admin interface and in our case is less important.
I also disabled the option of showing the drop down by turning $showSitesSelection to false

So even when i use the admin to see data, i will not load all these sites into the dropdown.
This is pretty much solved my problems. thx

@robocoder
Copy link
Contributor

Yes, 80K domains would be a problem. The memory exhausted error depends on your memory_limit in php.ini. My test with 23,000 domains maxed out my 32MB limit, which is around the norm. Using strcasecmp() instead of strtolower() would eliminate a lot of string conversions and small string allocations, but transferring 80K domains for the site selection list would still take a hit.

FYI showSitesSelection is set to true in several places:

```
plugins/Widgetize/templates/index.tpl
plugins/Live/templates/index.tpl
plugins/CoreHome/templates/index.tpl
plugins/API/templates/listAllAPI.tpl
```

I’d like to propose adding a config option (e.g., threshhold) to accommodate larger installations like yours.

@mattab
Copy link
Member

mattab commented Jan 14, 2009

Fixed in 880

fix #495 Adding option in configuration file: show_website_selector_in_user_interface

; if set to true, the website selector will be displayed in the Piwik UI
; if your Piwik installation has thousands of websites, you may disable the website selector
; as it slows down the loading of the Piwik UI by setting this value to false

following vipsoft suggestion

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants