development shits

Recently I deal mainly with code rather than with the Administration so that the drama I stand with kodene are much more than server such, so I decided to just scribble down a few lines about the bullshit that I manage to get their. Hard getting ready to present your project what kind of force the opening of the dramatic parts

  • Първото нещо което което със сигурност щеше да създаде проблеми е изключването на javascript от браузърната поддръжка. Както всяка модерна апликация така и нашия инструмент използва доста JS за AJAX and other dynamic processes which transmit the interactivity and contemporary vision and improves functionality. We thought about a lot of decisions as the most acceptable was a cookie with information and then php to check whether the information is valid, and if everything is OK. Quite literate solution but finally appear even more decent version. HTML to be implemented in noscript. I think it's the most elegant solution.
<noscript>
<meta http-equiv="refresh" content="0;URL=./nojs.html" />
</noscript>

Basically the situation is trivial if we stop JS support will be redirected to URnojs.html. Simple and very effective solution

  • Php multhithreading – very niškovosta's just something pretty useful for processors with more core (not that the ednoâdreni is not OK but with many nuclear systems are another things beer). Our software has a part that deals with the collection of information from other API – and importva it in our database. Obŝovzeto no challenge except that we implemented the php again with multhithreading in cli mode, because this process is enough big and need to be atomatiziran for having someone doing it by hand. Here there was a drama associated with fokrvaneto of processes and does not create the stream child process-(a) that he was waiting for a script to priklûčabota to create a new. Stupid it kills the idea of what behavior actually multiprocessing is not the multhithreading but here are the details. First we put & After the trial, which means your script to continue work but again there was no change in behaviour is required and the standard output from the script to be redirected – in my case the OK to /dev/null 🙂 Накрая структурата на тази част от кода изглеждаше така
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
}else if ($pid) {
// we are the parent
echo "I'm parent  \n";
pcntl_wait($status); //Protect against Zombie children
} else {
// we are the child
echo "I'm a child $timer  \n";
exec("$command > /dev/null &");
exit (0);
}

Primerčeto again is trivial. The performance was highly impressed with the interrupted between the processes and so forth I made about 50 child process-which made a turn away 7800+ mysql inserts for about 30-40 SEC. And the machine is extremely delicate because we test v″r″r before to make the application of the real.

  • Mysql querys – I was shocked by a great stupidity. There was a code that did 4-5 unnecessary queries to the database, instead of using a sql query and then fat main job it php-it. The drama was such, most- next was a request that took information from the query output is then used to make other requests as she served for the arguments. Pretty ugly and fat situation. Subquery and apparently is unfamiliar territory and left join or simply have not been abstracted things well. I got everything I rewrote the application work quite well and the load as a whole fell by about 200% for the same part of the code.

В общи линии това са нещата на последък с които се заниамваме и немога да кажа че е скучно но понякога се изумявам от разни необмисляни парчета код които трябва да поправям а най стеращното е че често са мои 😆

Enhanced by Zemanta

2 comments

  1. И аз имам тегления на данни, сложени в crontab-a. Пробвах преди със & в края, но ставаше пиково натоварване, грозна история. Сега съм ги оставил, като свърши единия процес, да пуска другия, но това е ужасТ :> Като зацикли някъде и всичко отива по дяволитетова го решавам като килвам старите процеси, като дойде време да се пуска новия, но това е още по-голям ужасТ, защото губя данни. Та ще се се опитам да имплементирам, твоето решене по този въпрос. Благодарско! 🙂

    1. Ами по моя метод хубавото е че информацията може да се обработва от няколко процеса едновременно но това също ти гарантира по голямо натоварване 😉 Баланса между натоварване и скорост винаги е много тънък. Всичко опира до тестове.

leave a reply

Your email address will not be published. Required fields are marked *

anti SPAM *