rtyug

rtyug
Рейтинг
263
Регистрация
13.05.2009
Должность
perl,php,sql,javascript(jquery),freebsd/linux
Интересы
perl,php,sql,javascript(jquery),freebsd/linux
https://minfin.com.ua/blogs/94589307/115366/

netwind, еще можно попробовать конфиг my.cnf оптимизировать, выделить больше памяти под ключи т.д. ?

я вот хотел сделать портал http://www.x0.org.ua/

только руки не доходят его закончить :)

тут http://www.x0.org.ua/groups хотел сделать, чтобы в портале пользователь создавал себе свой портал очень расширенный (чтобы как соц.сеть создавал...)

Andreyka:
А с каких пор 220k файлов это стало много?
Если конечно не держать их в одной директории.

Или это просто много для zfs?

нет, проблема может быть в том как именно открываются эти файлы (так как используется самописный скрипт)

по крайней мере можно так предположить...? :)

тоже, самое может быть, если 10-50к сокетов каждую секунду толкать не правильно (не оптимизированно) в многопоточность, то ОС может жрать память и отвалится... (и на сервере и на клиенте *{*$ на клиенте в случае инициализации})

PostgreSQL

сервант может где-то 1-2Гиг

Andreyka:
zfs - кака?

у ТС файлов очень много, даже очень много и их надо все сразу отдать одним куском, как я понял...

тут большая нарузка будет на ядро и на fs, (точно не знаю как тут сказать, все будет на IO винчестера)

РСУБД будет эмулировать носитель инфрмации, так же можно сетевой носитель информации (с репликацией)

тут вообще-то долго все перечислять, можно многое написать :)

http://www.khmere.com/freebsd_book/html/ch06.html

6.1 Advanced I/O and Process Resources

As we have seen from the previous chapter, programs can have multiple file descriptors open at the same time. These file descriptors aren't necessarily files, but can be fifos, pipes, or sockets. As such, the ability to multiplex these open descriptors becomes important. For example, consider a simple mail reader program, like pine. It should of course allow the user to not only read and write email, but also simultaneously check for new email. That means the program receives input from at least two sources at any given point: one source is the user, the other is the descriptor checking for new mail. Handling multiplexing descriptors is a complex issue. One method is to mark all open descriptors non-blocking (O_NONBLOCK), and then loop through them until one is found that will allow an I/O operation. The problem with this approach is that the program constantly loops, and if no I/O is available for a long time, the process will tie up the CPU. Your CPU load only worsens when multiple processes are looping on a small set of descriptors.

Another approach is to set signal handlers to catch when I/O is available, and then put the process to sleep. This sounds good in theory, if you only have a few open descriptors and infrequent I/O requests. Because the process is sleeping, it will not tie up the CPU, and it will then only execute when I/O is available. However, the problem with this approach is that signal handling is somewhat expensive. For example a web server receiving 100 requests per minute, would need to catch signals almost constantly. The overhead from catching hundreds of signals per minute would be significant, not only for the process but for the kernel to send these signals as well.

So far, both options are limited and ineffective, with the common problem being that a process needs to know when I/O is available. However, this information is actually only known in advance by the kernel, because the kernel ultimately handles all the open descriptors on the system. For example, when a process sends data over a fifo to another, the sending process calls write, which is a system call and thus involves the kernel. The receiver will not know until the write system call is executed by the sender. So, a better way to multiplex file descriptors suggests itself: have the kernel manage it for the process. In other words, send the kernel a list of open descriptors and then wait until the kernel has one or more ready, or until a time-out has expired.

This is the approach taken by the select(), poll() and kqueue() interfaces. Through these, the kernel will manage the descriptors and awake the process when I/O is available. These interfaces elegantly handle the problems mentioned above. The process doesn't need to loop through the open descriptors, nor does it need to handle signals. The process will still incur a slight overhead, however, when using these functions. This is because the I/O operations are executed after the return from these interfaces. Thus it takes at least two system calls to perform any operation. For example, say your program has two descriptors used for reading. You use select and wait for them to have data to read. This requires the process to first call select, and then when select returns, to call read on the descriptor. More ideally, you could do a large blocking read against all of the open descriptors. Once one is ready to read, the read will return with the data inside the buffer and an indication of which descriptor the data was read from.
6.4 kqueue

So far, poll and select seem like elegant ways to multiplex file descriptors. To use either of those two functions, however, you need to create the list of descriptors, then send them to kernel, and then upon return, look through the list again. That seems a bit inefficient. A better model would be to give the descriptor list to the kernel and then wait. Once one or more events happen, the kernel can notify the process with a list of only the file descriptors which had events, avoiding loops through the entire list every time a function returns. Although this small gain is not noticeable if the process only has a few descriptors open, for programs with thousands of open file descriptors, the performance gains are significant. This was one of the main goals behind the creation of kqueue. Also, the designers wanted a process to be able to detect a wider variety of events, such as file modification, file deletion, signals delivered, or a child process exit, with a flexible function call that subsumed other tasks. Handling signals, multiplexing file descriptors, and waiting for child processes can all be wrapped into this single kqueue interface because they are all waiting for an event to occur.

в зависимости от силы ддос можно сделать разную высоко интеллектуальную систему...

например, в случае попадания в blacklist можно отредиректить на другой сервант, где показать статическую страницу на nginx с reCaptcha, чтобы там конкретный айпи смог себя разблокировать пройдя капчу... ну на этом серванте, тоже, сделать не большую защиту и т.д.

(nginx (или веб-сервер на epoll), думаю, может выдержать 10-20к/сек. соединенние, если показывать страницу 512-2000байт)

большое ддос идет как правило от вирусов, а они без интеллекта берут и досят, т.е. их можно обдурить... например, перенести сайт на другой домен и айпи :)

может быть нету доступа к репозиторию пакетов? или может он не написан?

все таки мало информации, я не знаю что это за система...

и может, что проблема не в этом :D

  • 11Гиг/50кб =~ 220к файлов
  • я не знаю, не смотрел как работает кэш в zfs... можно попробовать
  • про кэширование дискрипторов файлов: есть в nginx, вродебы скрипт не будет дергать ядро и фс все время как только будет чтение из файла
  • в MySQL спокойно можно хранить текст 50-70к
  • мне интересно, то как Вы размышляете, есть база 11Гиг, припустим пускай база будет 100-200Гб Oracle,
  • кстати, SUN разрабатывает новую ФС которая будет без ограничений и высокопроизводительная... написано, что инфорация о ней не доступна...
  • есть аналогичные распределенные ФС коммерческие и не коммерческий, например, MogileFS
ReifTer:
Такой вариант должен работать



$(".menu_click").click(function(){

top.location = $(this).attr('href');

});

нет, не работает:


.................

//markup
var button = $('<a href="#" class="jquery-ui-themeswitcher-trigger"><span class="jquery-ui-themeswitcher-icon"></span><span class="jquery-ui-themeswitcher-title">'+ options.initialText +'</span></a>');
var switcherpane = $('<div class="jquery-ui-themeswitcher"> <div id="themeGallery"> <ul> <li><a class="menu_click" href="http://jqueryui.com/themeroller/css/parseTheme.css.php"> <img src="http://www.x0.org.ua/images/79/thumbnail/2118.jpg" alt="UI Lightness" title="UI Lightness" /> <span class="themeName">UI lightness</span> </a></li> <li><a class="menu_click" href="http://jqueryui.com/themeroller/css/parseTheme.css.php"> <img src="http://www.x0.org.ua/images/79/thumbnail/2118.jpg" alt="UI Lightness" title="UI Lightness" /> <span class="themeName">UI lightness</span> </a></li> </ul> </div></div>').find('div').removeAttr('id');

$(".menu_click").click(function(){
top.location.href = $(this).attr('href');

});


.............

попробуй нажать там где комментарии:

http://www.x0.org.ua/photo/view/79/2120

(на самой странице кода много)

(но когда я нажимаю, то не работает, в консоле нету ничего...)

rtyug добавил 15-01-2011 в 08:24

UPD:

добавил:


/* Theme Loading
---------------------------------------------------------------------*/
switcherpane2.find('a').click(function(){


options2.onSelect();
if(options2.closeOnSelect && switcherpane2.is(':visible')){
top.location.href = $(this).attr('href');
switcherpane2.spHide(); }
return false;
});


top.location.href = $(this).attr('href');

UPD2:

есть вопрос:

я хочу поставить несколько таких списков...

из поставил...

но когда нажимаю на левый список, то открывается правый список...

http://www.x0.org.ua/photo/view/79/2120 (там где комментарии)

я все классы поменял на другие имена...

Но оно все равно открывает правый список, тогда когда нажимаю на левый...

как это исправить?

исходники:


<script>
$(document).ready(function(){
$('#switcher').themeswitcher();

$('#switcher2').themeswitcher2();

});
</script>


<tr><td align='center' >
<div id="switcher"></div>
</td><td align='center' >
<div id="switcher2"></div>
</td></tr>




<script type="text/javascript">
/* jQuery plugin themeswitcher
---------------------------------------------------------------------*/


$.fn.themeswitcher2 = function(settings2){
var options2 = jQuery.extend({
loadTheme: null,
initialText: 'Switch Theme',
width: 150,
height: 200,
buttonPreText: 'Theme: ',
closeOnSelect: true,
buttonHeight: 14,
cookieName: 'jquery-ui-theme',
onOpen: function(){},
onClose: function(){},
onSelect: function(){}
}, settings2);

//markup
var button = $('<a href="#" class="jquery-ui-themeswitcher-trigger2"><span class="jquery-ui-themeswitcher-icon2"></span><span class="jquery-ui-themeswitcher-title2">'+ options2.initialText +'</span></a>');
var switcherpane2 = $('<div class="jquery-ui-themeswitcher2"> <div id="themeGallery2"> <ul> <li><a href="http://www.x0.org.ua/photo/view/79/21210"> <img src="http://www.x0.org.ua/images/79/thumbnail/2121.jpg" alt="UI Lightness" title="UI Lightness" /> <span class="themeName">UI lightness</span> </a></li> <li><a href="http://www.x0.org.ua/photo/view/79/2122"> <img src="http://www.x0.org.ua/images/79/thumbnail/2122.jpg" alt="UI Lightness" title="UI Lightness" /> <span class="themeName">UI lightness</span> </a></li> </ul> </div></div>');



//button events
button.click(
function(){
if(switcherpane2.is(':visible')){ switcherpane2.spHide(); }
else{ switcherpane2.spShow(); }
return false;
}
);

//menu events (mouseout didn't work...)
switcherpane2.hover(
function(){},
function(){if(switcherpane2.is(':visible')){$(this).spHide();}}
);

//show/hide panel functions
$.fn.spShow = function(){ $(this).css({top: button.offset().top + options2.buttonHeight + 6, left: button.offset().left}).slideDown(50); button.css(button_active); options2.onOpen(); }
$.fn.spHide = function(){ $(this).slideUp(50, function(){options2.onClose();}); button.css(button_default); }


/* Theme Loading
---------------------------------------------------------------------*/
switcherpane2.find('a').click(function(){


options2.onSelect();
if(options2.closeOnSelect && switcherpane2.is(':visible')){
top.location.href = $(this).attr('href');
switcherpane2.spHide(); }
return false;
});

//function to append a new theme stylesheet with the new style changes
function updateCSS(locStr){
var cssLink = $('<link href="'+locStr+'" type="text/css" rel="Stylesheet" class="ui-theme" />');
$("head").append(cssLink);


if( $("link.ui-theme").size() > 3){
$("link.ui-theme:first").remove();
}
}

/* Inline CSS
---------------------------------------------------------------------*/
var button_default = {
fontFamily: 'Trebuchet MS, Verdana, sans-serif',
fontSize: '11px',
color: '#666',
background: '#eee url(http://jqueryui.com/themeroller/themeswitchertool/images/buttonbg.png) 50% 50% repeat-x',
border: '1px solid #ccc',
'-moz-border-radius': '6px',
'-webkit-border-radius': '6px',
textDecoration: 'none',
padding: '3px 3px 3px 8px',
width: options2.width - 11,//minus must match left and right padding
display: 'block',
height: options2.buttonHeight,
outline: '0'
};
var button_hover = {
'borderColor':'#bbb',
'background': '#f0f0f0',
cursor: 'pointer',
color: '#444'
};
var button_active = {
color: '#aaa',
background: '#000',
border: '1px solid #ccc',
borderBottom: 0,
'-moz-border-radius-bottomleft': 0,
'-webkit-border-bottom-left-radius': 0,
'-moz-border-radius-bottomright': 0,
'-webkit-border-bottom-right-radius': 0,
outline: '0'
};



//button css
button.css(button_default)
.hover(
function(){
$(this).css(button_hover);
},
function(){
if( !switcherpane2.is(':animated') && switcherpane2.is(':hidden') ){ $(this).css(button_default); }
}
)
.find('.jquery-ui-themeswitcher-icon').css({
float: 'right',
width: '16px',
height: '16px',
background: 'url(http://jqueryui.com/themeroller/themeswitchertool/images/icon_color_arrow.gif) 50% 50% no-repeat'
});
//pane css
switcherpane2.css({
position: 'absolute',
float: 'left',
fontFamily: 'Trebuchet MS, Verdana, sans-serif',
fontSize: '12px',
background: '#000',
color: '#fff',
padding: '8px 3px 3px',
border: '1px solid #ccc',
'-moz-border-radius-bottomleft': '6px',
'-webkit-border-bottom-left-radius': '6px',
'-moz-border-radius-bottomright': '6px',
'-webkit-border-bottom-right-radius': '6px',
borderTop: 0,
zIndex: 999999,
width: options2.width-6//minus must match left and right padding
})
.find('ul').css({
listStyle: 'none',
margin: '0',
padding: '0',
overflow: 'auto',
height: options2.height
}).end()
.find('li').hover(
function(){
$(this).css({
'borderColor':'#555',
'background': 'url(http://jqueryui.com/themeroller/themeswitchertool/images/menuhoverbg.png) 50% 50% repeat-x',
cursor: 'pointer'
});
},
function(){
$(this).css({
'borderColor':'#111',
'background': '#000',
cursor: 'auto'
});
}
).css({
width: options2.width-30,
height: '',
padding: '2px',
margin: '1px',
border: '1px solid #111',
'-moz-border-radius': '4px',
clear: 'left',
float: 'left'
}).end()
.find('a').css({
color: '#aaa',
textDecoration: 'none',
float: 'left',
width: '100%',
outline: '0'
}).end()
.find('img').css({
float: 'left',
border: '1px solid #333',
margin: '0 2px'
}).end()
.find('.themeName').css({
float: 'left',
margin: '3px 0'
}).end();



$(this).append(button);
$('body').append(switcherpane2);
switcherpane2.hide();


return this;
};







</script>




rtyug добавил 15-01-2011 в 09:17

UPD3:

сделал!

надо было изменить имена этих функций в другом списке:


$.fn.spShow = function(){ $(this).css({top: button.offset().top + options.buttonHeight + 6, left: button.offset().left}).slideDown(50); button.css(button_active); options.onOpen(); }
$.fn.spHide = function(){ $(this).slideUp(50, function(){options.onClose();}); button.css(button_default); }

т.е. поставить:

$.fn.spShow2

$.fn.spHide2

G.Vad!k:
Возможно для этих целей понадобится это

я нашел вот на jquery UI

исходники http://jqueryui.com/themeroller/themeswitchertool/

http://jqueryui.com/docs/Theming/ThemeSwitcher

все работает, но я не понимаю, как сделать редирект при нажатии на кликабельную картинку??

я пробовал:

 $(".menu_click").click(function(){


top.location.href = $(".menu_click").attr('href');

});

в консоле firefox ничего не было...

как и куда тут http://jqueryui.com/themeroller/themeswitchertool/ добавить, чтобы при щелчке был редирект...?

пробовал много раз - никак не хочет...

Всего: 2062