Jump to content

brentman

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by brentman

  1. I have another table that I suspect is having collisions as well as I still am seeing decrease performance with more scripts running although now I am up to 5 before performance degrades. This one cannot be fixed simply with InnoDB though. Lesson from thread, pay more attention to query and DB design. At work but will get some code posted later or this weekend.
  2. Found the problem. My main table was not set on InnoDB *facepalm* so each instance I was making was waiting to complete updates and with each new instance it made it run slower and slower as it was having to wait for more likely collisions on the table. Quick change made it significantly faster but I will play around more with it later and see if that is the only problem.
  3. 1. Well it doesn't send emails but it runs through all the loops and things, just doesn't actually send it out. 2. They are the same server. It has multiple cpanel accounts with a different domain and ip for each. *The end goal is to have it on different servers at some point so it isn't helpful for me to make it a one server solution.
  4. No. All the data is on Server A. It sends the data to other servers B, C and D who actually send the email out. Currently, it is all done on one machine but under different cpanel accounts, domains, ips. In the future I will be moving it/ adding more on other physical machines, or at least should have the option. The actual code that emails is pasted prior in the thread. It cannot possibly be the http request because I can comment it out and there isn't a significant increase in performance. It's about 10%. I am running a duel hexacore 2.4ghz, it really should be able to handle running a php loop and some queries so that shouldn't be the problem. And without the http request that cannot be the problem either. It does do about 6 mysql queries one of which is checking against a table of 700,000 records, the others are checking against other tables with about 100k records and one pulling the info and one writing the final statuses and stuff. All of which is in a loop. Each record does need to be checked just prior to emailing so I cannot significantly change the function that is taking place. Although I have tried commenting it out just to test and it had very little effect on performance. The entire file is 484 lines with plenty of spacing and such, just to give you an idea of how much is going on. Most of it falls into two features, one is manipulating the message. ie Dear Joe to joe but Hey Friend to someone without a name etc. each email is quite personalized, more so than most people are doing. The second main feature is checking the email vs all my black lists I have acquired and other checks for proper formatting, likelyhood of being good address, etc. ie. brentman@gmail.com is ok to send to but brentman@northkorea.kp is not ok.
  5. Sure. I just commented it out and ran it again and it was only about 10% faster. That still isn't my main bottleneck. Check this: 1 Instance 1.97 Seconds/Email | Single Script Speed 1.60 Seconds/Email 2 Instances 1.37 Seconds/Email | Single Script Speed 1.98 Seconds/Email each 3 Instances 1.10 Seconds/Email | Single Script Speed 2.51 Seconds/Email each 4 Instances 1.04 Seconds/Email | Single Script Speed 3.10 Seconds/Email each They are measured slightly different (so don't try to run math on it) but the trend is what is bothering me? Why would running a script once vs twice vs 3 vs 4 times make a difference in the performance of the script on an individual basis unless as a whole they are maxing something out. There is no difference between a spammer and a regular emailer other than spammers don't have people opt in to be contacted and legit people do. I have people opt in to me and I provide a way to unsubscribe from my newsletters that I am sending, therefore not spammer. Lets talk about the topic please.
  6. I replaced file_get_contents with the following cURL: // GET Options curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $api_string, CURLOPT_USERAGENT => 'Codular Sample cURL Request' )); // Send Request $resp = curl_exec($curl); $htmlAttr = ($resp === FALSE)?'false':'success'; Improvement was negligible... ballpark of maybe 4% speed increase.
  7. I don't need to go crazy. It should be able to be accomplished with one machine. I am using like 1% of the machine power! Would using curl or fsocket be faster? I have never seen an example of asynchronous done so I don't really know where to begin logically to make that work. Google has not been extremely helpful with this either. Found this that looks interesting as well: http://php.net/curl_multi_init
  8. This is what I am doing: //bunch of logic up here $to = 'jones@yahoo.com'; $from = 'admin'; $subject = 'Hello, quick reminder about your account'; $body = 'body here'; $random_domain = rand(1,2); if ($random_domain == 1) { $domain = 'mysite.com'; } else { $domain = 'myblog.net'; } file_get_contents('http://' . $domain . '/?to=' . $to . '&from=' . $from . '@' . $domain . '&subject=' . $subject . '&body=' . $body); //end script Then the file I am file getting contents from is what I pasted above in prior message. This way the message is all generated in one file but two different domains send it out. On each of myblog.net and mysite.com have the actual mail() command script on them.
  9. I am a professional emailer. I have all that under control. Been out for awhile but now I am back and I don't want to spend $1000 to make $1000 you know? No I email to peoples lists on their behalf. No spamming. I am not totally sure what you are suggesting instead. Reason I am doing this is so that I can send email from two different domains.
  10. I am not using a mail service. They are pretty expensive. To even just mail the volume I am currently doing with the server would cost me about $750 per month. I don't know much about mail servers. Do you have any recommendations I can look into?
  11. I found this too but I don't know really what it does. http://pear.php.net/package/Mail
  12. Well I know of email systems that email off servers much faster. They may not be using php though. I tried using multiple instances and it kinda went faster. I was able to achieve about 70/min but I couldn't get it to stay at that rate, it fluctuated wildly as the instances started and stopped. I am not opposed to switching languages or whatever to get it going. I really need to figure this out. Totally different realm of code but MailChimp uses php and they are mailing 400mm per day for their clients. So it has to be possible.
  13. I am emailing off my server and its really slow. I think the problem is my logic, not the code. Current speed is about 30-40 emails per minute. I need to get it up to at least 175/min but I was really hoping for more like 700/min. The server is a Dual Hexa-Core 2.4Ghz with 32gb ram and dedicated to only this task. All server reports show low resource usage. The logic flow is like this: 1. Get email content. 2. Loop through records in database. 3. Check record against some other tables (ie unsubscribe table) 4. If record checks then send email by file_get_contents passing all the email content through get variables. 5. Other script is basic email script. See below: <?php //GET VAR INPUT $to = htmlentities($_GET['to']); $friendly_from = htmlentities($_GET['friendly_from']); $email_from = htmlentities($_GET['email_from']); $subject = htmlentities($_GET['subject']); $text = htmlentities($_GET['text']); $html = $_GET['html']; $html = '<head><title>' . $subject . '</title></head><body>' . $html . '</body>'; //SEND EMAIL # Setup mime boundary $mime_boundary = 'Multipart_Boundary_x' . md5(time()) . 'x'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers .= "Reply-To: " . $email_from . " \r\n"; # Add in plain text version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $text; $body.= "\n\n"; # Add in HTML version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/html; charset=\"UTF-8\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $html; $body.= "\n\n"; # End email $body.= "--$mime_boundary--\n"; # <-- Notice trailing --, required to close email body for mime's # Finish off headers $headers .= "From: " . $friendly_from . " <" . $email_from . ">\r\n"; $headers .= "X-Sender-IP: " . $_SERVER[SERVER_ADDR] . "\r\n"; $headers .= 'Date: ' . date('n/d/Y g:i A') . "\r\n"; //Mail it out $response = mail($to, $subject, $body, $headers); //RESPONSE (Success = 1, Fail = 0) echo $response; die(); ?> The entire thing runs on a cron job every minute checking with a lock to prevent multiple instances as the file usually executes for about 5 minutes. I have tried turning off parts of the code and retesting such as many of my database look ups but as you would expect they optimize by like 1% or something very little like that. The thing that takes a long time is the actual sending of the email. So how to get that to go faster?
  14. Yes I do. I am using htmlentities on the variables right before this and it is password protected pages that are only for me.
  15. Anyone feel free to use the code I have for mailing, it appears to work well.
  16. Solved: wow htmlentities() caused the problem. That was stupid. Nobody say anything.
  17. I am trying to send a basic email that is multipart via the mail() function in php. I am not interested in using PHPmail. This should be very light weight. Currently when I send email to gmail, it is sending the html part as plain text so all the tags are showing. Here is my code: //GET VAR INPUT $to = htmlentities($_GET['to']); $friendly_from = htmlentities($_GET['friendly_from']); $email_from = htmlentities($_GET['email_from']); $subject = htmlentities($_GET['subject']); $text = htmlentities($_GET['text']); $html = htmlentities($_GET['html']); //SEND EMAIL # Setup mime boundary $mime_boundary = 'Multipart_Boundary_x' . md5(time()) . 'x'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers .= "Reply-To: " . $email_from . " \r\n"; # Add in plain text version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $text; $body.= "\n\n"; # Add in HTML version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/html; charset=\"UTF-8\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $html; $body.= "\n\n"; # End email $body.= "--$mime_boundary--\n"; # <-- Notice trailing --, required to close email body for mime's # Finish off headers $headers .= "From: " . $friendly_from . " <" . $email_from . ">\r\n"; $headers .= "X-Sender-IP: " . $_SERVER[SERVER_ADDR] . "\r\n"; $headers .= 'Date: ' . date('n/d/Y g:i A') . "\r\n"; # Mail it out return mail($to, $subject, $body, $headers); Here is what I am receiving. (And yes I can accept html emails).
  18. Also btw: I tried going down my big file that is all php that is the iframe and the variables make it all the way through to a large complex mysql query and that is where it stops. The query has not changed in any way. So it is obviously something wrong with the mysql database I think. I am just at a loss of what to check on or how to permanently fix the issue.
  19. I have been working on a php application and spent a lot of time on it. I have finally finished. Only one problem. The weirdest bug keeps happening. I have a file that has one place where it reads the database and echos out an iframe and some CSS. It is a pretty simple file. There are no database writes in it. Every time I go in there and try to edit my CSS, my database breaks. What happens is the iframe (which does contain writes and lots of complex logic) has two inputs and one output. When I run this file on its own, I can do it all day long with no problems. When I run the URL with it in as an iframe, no problems. When I open the file and make any change to the CSS, it breaks. I set the changes back how they were yet it still will not work. I clear all the data out of the database incase there was a bad write of data. Does not work. The only thing that works is I download a current backup of the database (even in the broken form) and reupload it. THIS WORKS! What is going on here! What should I do (besides not ever editing css on my site ever again)? I am going crazy over this!
  20. Just did that right when I saw that ugh *facepalm*. Hourly is close enough for now. Thanks.
  21. function to_email($input) { require_once('dbconnect.php'); echo time(); $result = mysql_query("SELECT * FROM usertable WHERE HOUR(NOW()) = HOUR(FROM_UNIXTIME(opt_time))"); $row = mysql_fetch_array($result); echo mysql_num_rows($row); } usertable one records opt_time value is 1424557192 I ran the script and it echoed: 1424557019 And this error: Warning: mysql_num_rows() expects parameter 1 to be resource, array given in /home/mysite/public_html/api/index.php on line 45
  22. Well that looks pretty easy, I like it. But what happens if I need only 30 minutes? What about 2 hours? I am not quite sure of how often the cron job will run yet.
  23. I have users who signed up for an email list and there is a table of them and the join date is in unix timestamp. I do not care about the date, only the time they signed up. I am putting together code to be run on cron to decide who gets emailed. It will be run probably every hour. When it runs the first thing I need it to do is select all users who from the current time through the next hour registered. This way I can then email people around the time they initially joined my site. Here is what I have: //$input is the minutes range (which will be most likely an hour so this variable should be 60) function to_email($input) { require_once('dbconnect.php'); $cur_hours = date('H'); $cur_minutes = date('i'); $cur_seconds = ($cur_minutes + ($cur_hours * 60)) * 60; $end_seconds = $input * 60; $end_seconds = $cur_seconds + $end_seconds; $result = mysql_query("SELECT * FROM usertable WHERE " . $cur_seconds . " <= (HOUR(opt_time)*60*60) + (MINUTE(opt_time)*60) + SECOND(opt_time) AND '" . $end_seconds . " > (HOUR(opt_time)*60*60) + (MINUTE(opt_time)*60) + SECOND(opt_time)'"); $row = mysql_fetch_array($result); } The php part works as what I think is needed. But the query does not. I am not very good at MySQL queries so don't judge.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.