-
Notifications
You must be signed in to change notification settings - Fork 16
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
Session Management #13
Comments
Hi Thiago, thanks for your report. I have made a heavy usage of this library and never faced this problem, but I was using it in a batch operations context. I do not know much about your context, but session storage and management would be something that your application should care about, not the library, as pointed in the link you sent. I can give you some tips however. First, is to reduce as much as you can the API usage. Use the limits per object (like sending 200 customers or products) per call. You will gain performance, and reduce your total api calls. Also, try to wrap everything that doesn't really need to be real-time into jobs/batches that run every 5 or 10 minutes. This may be your solution. Well, let me know any further questions. I'm waiting you to close this issue. |
Thanks for your reply @davispeixoto I'm using the Salesforce connection to request data, every user that visits my site make a new request. This query returns a list of dealerships to the user, then a form is sent based on the selected dealer. You are right, this is not an issue of the library. I don't know exactly how to deal with this. All dealers are constantly changing I think that caching this query is not a viable solution. Maybe creating a task that fetch the data from Salesforce and save on my local database could solve the problem this will reduce the requests / logins. |
@thiagocoelho , one possible solution is to determine the frequency of those changes and then, based on this, decide to prime your cache (or not). I've also googled for serialize a php soap client but seems that no one recommends that with the PHP native soap client library - and unfortunately, that's the one used by the original Force.com Toolkit. But the idea was to keep a serialized and shared resource. Now, a little bit more analysis at your process. Are there too many requests per client? Or too many clients making just a few connections and requests each? For the first case, the link you sent about saving the connection on the php session should work. For the second, caching or serializing/sharing the connection would solve the problem. |
Everytime a user access any page that has a map like this: http://www.caoa.com.br/concessionarias A new request is made to get all dealerships to be used in the map. The same request is made when the user wants to send a contact form. So it's basically one / two requests per client. I think that saving the connection (session id) could solve the problem of maximum logins (3600 logins per user / hour). I can't figure out how to save this sessionId or even if it's possible to save it. So the last login could be used in more than one query. Anyway I'm sorry, think this is not a question related to your project anymore :/ |
@thiagocoelho , I see two ways you can solve your problem. First, would be forking and tuning my library. It is stable enough as of now (Salesforce is not planning to break their technology or implementation, nor Laravel is going any further at version 4 or 5 LTS that could break backwards compatibility) to you fork, change and use as needed. Basically you need to change the class instantiation, to follow the link you passed about storing the ids in a session other than login in with connect method. The second, would be using my Force.com Toolkit library from packagist (the Salesforce original cannot be properly loaded in a PSR-0 context). Thus you can implement exactly the way from the link you passed. The downside is having to adapt almost all your application calls. Feel free to contact me directly by email - I'm brazilian too, and we can speak plain portuguese via email. I'm closing this issue. See you. |
Hi everyone. If you look at the code wrote in Salesforce.php, in the constructor you have the login to salesforce. (Same problem in the Laravel 5 repository on this) So i try something, i do a var_dump on that class just before the try with a return true, and i launch php artisan tail, i got 2 times my var dump, so i got 2 login at Salesforce (and i can see it on Salesforce Website). The problem is (i think) that the login is on the constructor and not on a singleton or a getInstance method. (Like Zuora API) So every time you call that class you have a login.. Someone have a clue for what's going on ? |
I'm not sure yet the reason it is called twice. I will perform a debug on it. But the reason it is called whenever you call a simple php artisan tail is really clear for me. The service provider class declare it with defer false. This means the login is always made upon the application bootstrap, whether it is used or not. I suspect it is made twice because I declare two aliases for it (Salesforce and SF). But as I said, I need to instrument it with a tracer. |
@thiagocoelho and @AlexLombry , thank you for bringing up this point. Despite being just a bridge between the native Salesforce Force.com PHP Tookit and a framework, you guys made me found a little more room for improving this library. I'm planning to make a major upgrade in order to provide a better session management through a caching mechanism. And by major, I mean this new version won't be backward compatible. I will be a 2.0 version, and the installation and configuration will be a little different - but it will perform better. Thanks again, folks. |
@davispeixoto You're welcome. I think it's a very good idea. The big problem is that Salesforce has limited request even for Login so if you can do some caching management to avoid that, it would be great 👍 |
That's the idea. Cache logins. |
That's awesome! I'm happy that this question bring a new feature for the library. There is always space for improvements in the open source community 👍 I was about to do that by myself but at the end, I've made just an adjustment in my project to stop the high amount of login requests. Anyway, I'm pretty sure that in the future I will need this session management. |
Upgrade done. |
Hello :)
I've been using your package for a long time and I'm facing a problem with login rate.
Other Apex API Taxa de login excedida
Seems that every call I'm doing through Salesforce a new login is made.
So I'm thinking if it's possible to store the current login session to be used until the expiration time is reached.
Maybe something like this: https://developer.salesforce.com/page/Getting_Started_with_the_Force.com_Toolkit_for_PHP#Session_Management
I'm not sure of how this could be implemented or even if I'm doing something wrong.
The text was updated successfully, but these errors were encountered: